Tag Info

New answers tagged

3

Firstly you could replace the && with ; which is equivalent to the line breaks in your multiple-line code. Secondly I don't think you need the && (or ;) after the then statement. The difference between the && and ; line breaks is that && will run the next block of code if and only if the previous block has executed properly. ...


0

Self solution As long as $line will never equal to "FILECHANGE," (most likely never in my case) this will work x=1 for line in $(cat foo) FILECHANGE $(cat bar) do if [ $line = FILECHANGE ] ; then x=2 ; fi if [ $x = 1 ] && [ $line != FILECHANGE ] then echo 1 elif [ $x = 2 ] && [ $line != FILECHANGE ] then ...


1

What about this? for line in $(grep '^.*$' foo /dev/null) $(grep '^.*$' bar /dev/null) do if [[ ${line} =~ ^foo.*$ ]] then action1 else action2 fi done If you want to strip the leading filenames in $line you can add line=$(<<<$line sed 's/^foo:\(.*\)$/\1/') and line=$(<<<$line sed 's/^bar:\(.*\)$/\1/') ...


0

if grep -qx "$line" file1 To your for line: your files foo and bar should not contain lines with whitespaces. It might be better to use a cat foo bar | while read line; do ... done loop.


1

As the error states there is no cmap.bin in /media/xavi/Elements/ubuntu_programes/. Check if the file has the right name: Change to the directory with cd /media/xavi/Elements/ubuntu_programes/ and list the files with ls -la If the file has the wrong name change it with: mv wrongFileName cmap.bin If it does not exist at all copy it there with: cp ...


2

To see the kernal driver that manages your network interface card, type sudo lshw -C network and look at the driver entry, or use: lspci -v and look at the Kernel driver in use for your network and Ethernet controller


5

To kill a process on a port you can do: $ fuser -n tcp -k 443 && /opt/lampp/xampp start Change the && to ; if you want it to start xampp no matter if there was anything running on that port or not.


0

Use grep for empty lines: grep . file Or try the ex-way (cross-platform compatible) for blank lines (e.g. containing whitespaces): ex -s +'v/\S/d' -cwq test.txt For multiple files (edit in-place): ex -s +'bufdo!v/\S/d' -cxa *.txt Without modifying the file (just print on the standard output): cat test.txt | ex -s +'v/\S/d' +%p +q! /dev/stdin


4

Using C (note that main() usually returns an int): #include <stdio.h> #include <stdlib.h> int main() { int ret; ret=system("fuser -k 443/tcp; /opt/lampp/xampp start"); return ret; } Or simply using bash: fuser -k 443/tcp; /opt/lampp/xampp start Using ; in place of && in either methods makes /opt/lampp/xampp start ...


4

It is failing because you are searching in the current directory and not the target. Change your find to: find "$d" -type f -exec ls -al {} \; | sort -nr -k5 | head -n 1 However, a safer way would be: #!/bin/bash for d in */ ; do file=$(find "$d" -type f -printf "%s\t%f\n" | sort -n | tail -n 1 | cut -f 2- ) echo "$file" mv "$d${file}" . done ...


2

Use this find "$d" -type f ... instead of find . -type f ... . is your current folder and you mean the elements provided by $d.


0

You can insert your SIM card in the slot and follow the instructions given here. In short, after you insert your SIM card, type Network connections in the dash and click Add, select Mobile Broadband and follow the on-screen instructions. Also you need appropriate drivers for the slot to work. To see if there's any, go to System Settings - Software and ...


2

From the commands you have provided, it is clear that you are trying to load two modules into the kernel in the runtime after just starting your computer. This can be done easily by the /etc/modules file. This file is the designated place to put the modules that will be loaded into the kernel upon system boot every time. In your case, to load the mentioned ...


0

Just do this If you are on Ubuntu naren@kadmin-KCPL190: sudo su Then you will now be a root user and can do anything root@kadmin-KCPL190:# dpkg -i libmotif*i386.deb will work Be careful. If you set a password for root user then it asks you the same for landing to root.Else it will just make you superuser.


1

I'd put both your export definitions and the alias commands to your .bashrc.


0

To answer you questions: ".....could I have any way to come back on android?" : You can re-install the android image if you indeed have one backed up or downloaded from somewhere. "..could i have my android platform": If you install Ubuntu touch, you will lose android and if you re-install android, it will remove Ubuntu. Be warned that your device is ...


0

AFAIK the recommended way is to use pkcon. Copy your .click file to the device and run the following command on the device itself (by using adb shell or SSH): pkcon --allow-untrusted install-local com.ubuntu.developer.abc.def_0.123_armhf.click This does not require root privileges.


0

sudo uses your user's password, it is the same you enter when logging in. You can try changing your password with passwd.


2

while read file; do split <some options> "$file"; done < list.txt If your file names can contain whitespace or backslashes, use this instead: while IFS= read -r file; do split <some options> "$file"; done < list.txt


3

In order to be sure no line break you can use other option than c. split -n #number split a file by #number chunks so you can thus be sure they are equal and more no break in lines.Example split -n 4 file.txt This will split the file.txt into 4 chunks. OR you can split by number of lines split -l #number-of-lines example split -l 200 file.txt ...


1

Here is a perl script to determine the size of each Git commit: The source is here, I have added one modification: #!/usr/bin/perl foreach my $rev (`git rev-list --all --pretty=oneline`) { my $tot = 0; ($sha = $rev) =~ s/\s.*$//; foreach my $blob (`git diff-tree -r -c -M -C --no-commit-id $sha`) { $blob = (split /\s/, $blob)[3]; next if $blob ...


2

If you're running it in a loop, you can redirect the output of the entire loop instead. for (( i = 0; i < n; i++ )); do somecommand done > ~/Desktop/file.txt If it's a bit more complex (e.g. other things outputting as well), you can open it on a separate file descriptor. exec 3> ~/Desktop/file.txt ... somecommand >&3 ... somecommand ...


1

You want >>, not >, like this: command >> /path/to/file.txt


3

Use '>>'. command >> ~/Desktop/file.txt


3

Use >> instead of >: command >> ~/Desktop/file.txt While you were using command > ~/Desktop/file.txt, the file ~/Desktop/file.txt was opened by shell for writing the content of STDOUT (file descriptor 1). So the file's content will get overwritten every time you run the command. On the other hand, shell will open the file for appending ...


2

Sounds like the script contains some CR (\r) characters. If you have edited this script from windows, that would explain why. Running this should reveal the otherwise "invisible" carriage return characters: sed -n l /home/pi/sh/test.sh (That's lowercase L, not 1). If you see a \r in the above, see FAQ 52 for various ways to get rid of them. On a side ...


1

This sounds like a known, existing bug: lubuntu-default-settings does not specify the proper command to execute in terminal That bug report suggests the following workaround (using X-terminal instead.) WORKAROUND: In pcmanfm preferences, under the advanced tab, change the terminal to "x-terminal-emulator -e %s". You can also change the "terminal" ...


0

Here is the answer. Save the following script code as git-file-size-diff in your $PATH. The "git-" at the beginning in the filename is important. #!/bin/sh . git-sh-setup args=$(git rev-parse --sq "$@") eval "git diff-tree -r $args" | { total=0 while read A B C D M P do case $M in M) bytes=$(( $(git cat-file -s $D) - $(git cat-file -s $C) ...


0

You can use the click command to install packages on your device. First copy the .click file on your device. Then use the following commands (e.g after creating a remote session with phablet-shell): sudo click install --all-users ./com.ubuntu.foo_1.0.click --allow-unauthenticated click register com.ubuntu.foo 1.0 Just change the name of the package for ...


0

The error message you displayed is not shown because some process is using sudo. This indicates that you are doing some package management for your system (update, upgrade, install....) So with regard to your demand I'm afraid to say for you that you can't do that in Linux, since the package management always demand the lock to disable other user of ...


0

You may run the following script: Save the following script (say test_server.js): var http = require('http'); http.createServer(function (req, res) { res.writeHead(200, {'Content-Type': 'text/plain'}); res.end('Hello Node.js\n'); }).listen(8124, "127.0.0.1"); console.log('Server running at http://127.0.0.1:8124/'); Run the script using: nodejs ...


0

Create a file containing list of URLs called url.txt: http://www.url1.xxx http://www.url2.xxx http://www.url3.xxx Firefox uses the new-tab command, so you could pass the URLs in the file to the browser like so: xargs -a url.txt firefox -new-tab "$line"


0

New versions of Caffeine don't show up anywhere. They work in background and disable screensaver, when full-screen video is displayed. If you need that old cup for manual toggle, you can install caffeine-plus. sudo add-apt-repository ppa:nilarimogard/webupd8 sudo apt-get update sudo apt-get install caffeine-plus


0

To add the PPA, open terminal from the Dash or by pressing Ctrl+Alt+T. When it opens, run command: sudo add-apt-repository ppa:caffeine-developers/ppa After that, update package cache and install the indicator by running below two commands one by one: sudo apt-get update sudo apt-get install caffeine Now to run the caffeine indicator from terminal ...


2

Oops. I just found the answer. You need to add a -url after each `-new-tab'. firefox -new-tab -url https://www.evernote.com/Home.action -new-tab -url http://www.gmail.com Now it works. Hope this can help somebody.


0

sudo needs at least one execute bit set to execute the file i.e. you need to set the execute bit for (at least) user or group or others. If no execute bit is set you can't execute the file as sudo ./script. This example will make you clear: $ ls -l test_scr -rw-rw-r-- 1 user user 30 May 4 03:50 test_scr $ sudo ./test_scr sudo: ./test_scr: command not ...


1

You shall not include that line in .Xdefaults. Thus shalt thou start the program. xterm -ls -xrm 'XTerm*selectToClipboard:true' & Or with .Xdefaults: Add this line: XTerm*selectToClipboard:true and reload the configuration xrdb ~/.Xdefaults


3

Sounds like your script lacks a shebang line. Make sure the very first line of the script reads: #!/usr/bin/env bash or #!/bin/bash On a side note, you should avoid putting .sh extension on a bash script, since bash is not sh. Preferably use no extension at all.


0

whenever you use a command starting with sudo, it means that you are using the computer as a root privileged. And every command that make change to a computer should start with sudo because Linux needs to make sure the administrator is making those changes. you can also prompt a sudo sucommand before any other commands. so that you do not need to enter ...


0

Install ssmtp : sudo apt-get install ssmtp Edit the ssmtp config file : gksu gedit /etc/ssmtp/ssmtp.conf Add these lines in the file and don't forget to edit according to your needs root=username@gmail.com mailhub=smtp.gmail.com:465 rewriteDomain=gmail.com AuthUser=username AuthPass=password FromLineOverride=YES UseTLS=YES Enter the email address of the ...


0

The problem is that your script is intended for Linux and you are trying to run it in windows. As an example, the following script: for %%A IN (*.avi) DO ffmpeg -i "%%A" "%%A.mpg" converts all avi files (in windows). EDIT: Save this script in a text file and put in the same folder that contain the files and run the script from there.


0

My mechanism for this: vagrant global-status | grep virtualbox | cut -c 1-9 | while read line; do echo $line; vagrant halt $line; done; global-status lists all boxes filter that for lines containing virtualbox (Filters out the help text, will break if you're using some other provider) Filter that to display only the first 9 characters (the global unique ...


0

testdisk is well available in Vivid repos: testdisk (6.14-3build2) [universe] Just enable the universe repository: sudo add-apt-repository "deb http://archive.ubuntu.com/ubuntu $(lsb_release -sc) universe" sudo apt-get update sudo apt-get install testdisk


0

Thanks. Jacob's solution is just what I was looking for. <screen> is meant to replace the specific input that you need to provide to xrandr. To find out what that name of the input is, look at the first acronym that appears just before the list of numbers when you run xandr. In my case these were LVDS1 and VGA1 (the first is my laptop, the second ...


0

https://apps.ubuntu.com/cat/applications/precise/arandr/ ARandR is a visual front end for XRandR 1.2/1.3 (per display options), which provides full controll over positioning, saving and loading to/from shell scripts and easy integration with other applications. This is a program that allows you to save scripts. In turn, this eliminates having to set ...


0

Here's my attempt at this task: Step 1 - create a list of all the text files you want to have one word. Named mine list, and one perline listed text1, text2, text3, and text4 Step 2 - Create list of words , one per line. Mine is named word Step 3 - run the following command: pr -m -t words list | awk '{x=$2; print $1>x}' Now, of course, it's not a ...


0

Have you tried to delete the source.list file whit thunar, and use system settings and enter update, and hatch to to first option and reload, and then try to install it again, and it might work fine this way.


1

Trap the INT signal, eg: Ctrl+C more infos here trap trapint 2 function trapint { exit 0 } In your code like this: #!/bin/bash trap trapint 2 function trapint { exit 0 } sleep 2 while true; do feh --cycle-once -zD $1 *.png done


0

Do the same by combination of find and basename commands as follows: find /path/to/dir -name '*.time' -exec basename {} .time \; > someFile The basename {} .time, strips the ".time" suffix from fileNames. The {} represent the current found fileName.


0

One time for the duration of the session (ie. the compiling of the software): BUILD_OPT=1 USE_64=1 export BUILD_OPT export USE_64 You need to issue this before the make nss_build_all.



Top 50 recent answers are included