Tag Info

New answers tagged

0

rsync -aAXhv /home/levan/kdenlive/untitelds.mpg /media/sda3/SkyDrive/ This will copy the "untitelds.mpg" file in the SkyDrive directory without deleting anything


2

If you take a look through /etc/init folder, the command responsible for bringing up TTY is getty. For each TTY there is a *.conf file in /etc/init , so if you want colorized prompt on every TTY, you will have to edit every single one of those files. Now, the file responsible for the contents of that appear on the screen before logging in is /etc/issue, ...


3

Scripts execute commands in sequence, and wait until each command finishes. However, there is a way to allow the script to continue executing past a specific command - add & on the end of the script. For instance: !#/bin/bash firefox echo "Next line" Will wait till firefox is closed. !#/bin/bash firefox & echo "Next line" Will execute echo ...


1

First Q: [[ $word =~ ^(\....|.\...|..\..|...\.)c$ ]] Second Q: ps -ef


0

You could use exit statuses to deal with your case. Exit statuses are numerical values returned by a command to indicate whether the execution went well or not. The default value is 0 if it was a success, a number between [1..255] otherwise. Each value has a signification. For instance, you could rewrite your Processcheck like this : while read proc; do ...


1

#!/bin/bash adb shell "su dd if=/dev/block/mmcblk0 | /dev/examiner/nc -l -p 8888" The problem is that this way the pipe is executed in the unprivileged adb shell, and not in the root shell spawned by su; this leads to the pipe being executed without root privileges and to the 0-lenght file (probably due to the if command failing to read a block device ...


2

You may use sed inside the two command substitutions to process the original files prior their listing within the arguments of the program (thanks to steeldriver for the simplified pattern): program -input "$(sed "s@^\|,@&$source1@g" file1.txt)" -input2 "$(sed "s@^\|,@&$source2@g" file2.txt)" I changed the sed commands' default delimiter (/) to @ ...


1

I'm the maintainer of subliminal. Latest version of subliminal (1.0.1 as I'm writing this) brings a lot of fixes and a brand new command line interface that is much easier to work with and nicer to look. There is a soon-to-be-released example that integrates subliminal with the Nautilus file manager to add a right click context menu. Screenshot and install ...


0

Another solution using a for loop to collect the filenames into the $files variable, and the sequence of numbers between the two arguments provided as input parameters to your script, you could try the following: #!/bin/bash files="" a=$1 b=$2 for i in `seq $a $b`; do files="$files IMG_${i}.JPG" done scp $files user@192.168.1.2:/home/user/


3

You can use bash brace expansion : IMG_30{94..99}.JPG IMG_31{00..34}.JPG to generate file names from IMG_3094.JPG to IMG_3134.JPG. It actually has two expansions : IMG_30{94..99}.JPG will be expanded from IMG_3094.JPG to IMG_3099.JPG IMG_31{00..34}.JPG will be expanded from IMG_3100.JPG to IMG_3134.JPG So your scp can be done with this one liner : ...


2

This is not the way bash aliases work, all the psoitional parameters in the bash aliases are appened at the end of the command rather than the place you have defined. To get over it you need to use bash functions. An example will make you more clear : $ cat file.txt foo $ cat bar.txt foobar spamegg $ grep -f file.txt bar.txt foobar $ alias foo='grep -f ...


0

Using dialog, the command would look like this: dialog --clear --backtitle "Backtitle here" --title "Title here" --menu "Choose one of the following options:" 15 40 4 \ 1 "Option 1" \ 2 "Option 2" \ 3 "Option 3" Putting it in a script: #!/bin/bash HEIGHT=15 WIDTH=40 CHOICE_HEIGHT=4 BACKTITLE="Backtitle here" TITLE="Title here" MENU="Choose one of the ...


0

Here's a purely bc solution. Rounding rules: at +/- 0.5, round away from zero. Put the scale you're looking for in $result_scale; your math should be where $MATH is located in the bc command list: bc <<MATH h=0 scale=0 /* the magnitude of the result scale */ t=(10 ^ $result_scale) /* work with an extra digit */ scale=$result_scale + 1 /* your ...


-1

#!/bin/bash # "Two Words" Makes It Count As One Object, # But If It Is A Single Word,You Don't Need The "" select choice in "Start Server" "Update Server" Exit do case $REPLY in 1) echo Start Server... ;; 2) echo Update Server... ;; 3) echo "Okay, Exiting..." exit ...


0

This question might be a better fit for serverfault seeing as it's essentially about typical sysadmin jobs such as process management, rather than anything Ubuntu specific but anyway, an answer: What you're essentially talking about is a daemon process - that is a process that's started and monitored by the operating system, and restarted on failure. You ...


2

Try this: #!/bin/bash find ${PATH//:/ } -type f -executable 2>/dev/null | while read -r c; do ldd "$c" | grep -q -m 1 libX11.so [[ ${PIPESTATUS[1]} -eq 0 ]] && echo "${c##*/}" done See: man find, help while, help read, man ldd, man grep, man bash


2

You have used the classic "fork bomb" to use up all of your system's processes, and now your cannot get the system to run a process to help you (and all commands, programs, etc. require a process to run "in"). Any intervention will have to come from outside the system (e.g.,reset the VM, cycle the power, CtrlAltDelete). Did you not understand what then code ...


-1

YADR is not meant to work in ubuntu., you may wish to try an ubuntu variant, such as : https://github.com/renoirb/ubuntu-yadr


0

If you can't connect again, you do not have a chance. Maybe you can wait for an out of memory error If you can connect, try the command below pkill -f : And as you said in your comments I am running it in Virtual box Reset the machine via VirtualBox.


2

You might need to hard reboot the computer. Assuming you have console access, you might try to get the process group ID (PGID) and kill that with : kill -- -PGID Or use SIGKILL instead of SIGTERM : kill -9 -- -PGID but it might not be possible to get the PGID practically as the system might be already occupied by the forked processes creating a ...


3

To add another option: you can do away with square brackets and parentheses altogether by using the test built-in instead: if test $(ipcs|grep test|wc -l) -eq 630; then echo "Shared Memory check passed" fi The [ built-in essentially is an alias for the test built-in, except that it takes one additional argument: ]. This also illustrates that the [ ...


7

Essentially there are multiple ways to construct if conditionals in bash; one is outlined in A.B.'s answer; another one, which is likely the one you are trying to use, involves using double parentheses, which is a way to manipulate expressions / variables in bash in a more of a C-style way, and which, per its definition, requires double parentheses in order ...


10

Some syntax errors The base for the 'if' constructions in bash is this: if [ expression ]; then # code if 'expression' is true. fi here is the corrected version if [ "$(ipcs|grep test|wc -l)" -eq 630 ]; then echo "Shared Memory check passed" fi or with [[…]] to prevents word splitting of variable values without douple quotes if [[ ...


0

In terminal enter: gedit ~/.inputrc Then copy paste and save: "\e[A": history-search-backward "\e[B": history-search-forward "\e[C": forward-char "\e[D": backward-char From now on in terminal you can do incremental search, All you need to do to find a previous command is to enter say the first two or three letters and upward arrow will take you there ...


2

After some documentation search I was able find solution so I am gonna answer my question here. Open Gedit and go to "Tools" >> "Manage External Tools" and create new tool. Add following command just like below: echo -n $GEDIT_CURRENT_DOCUMENT_URI | xclip -sel clip;exit; Close it and then restart Gedit(just for confirmation). Open any document and then ...


1

You could run your system with the Universal timezone, or use the TZ environment variable env TZ=Universal date . Otherwise you are faced with configuring each application that 1) You use; and 2) displays the date.


2

How can I paste the selected text from gui and toggle to cli mode and then paste it there (especially in vim)? If your goal is to go to directly from GUI to TTY and paste, that's impossible. You have to have something in the middle, something in common between tty and gui. Terminal multiplexers such as screen, tmux, and byobu allow creating shared ...


2

File attributes are stored in inodes. The attributes that each inode stores are listed in POSIX Inode Specification. When we use ls -l or stat or any other program that get us the file attribute uses the stat(2) system call underneath. Now inodes are filesystem dependent property, they are created as fixed numbers when the filesystem is created. There is ...


0

An example as an answer Two scripts in the same path script1 #!/bin/bash ./otherScript echo "script1" | tee script1.log otherScript #!/bin/bash echo "otherScript" Lets start script1 and check the output % ./script1 otherScript script1 and the logfile script1.log, created in script1 % cat script1.log script1


2

This may not be a complete answer, but this is what I was able to find from my research. File attributes are stored in inodes and the 'inode tables' are generally scattered throughout the file-system. In general, to find where you have the inode tables (at least in ext3 filesystem), you can run: sudo dumpe2fs /dev/<device> | fgrep 'Inode table' and ...


0

To my surprise it is actually possible. First some setup: Install xclip. Switch to the virtual terminal with Ctrl-Alt-F1. Run alias pc='$(xclip -display :0 -out)'. Now, assuming you've copied some text and changed back to the VT: Type (don't run) pc. Press Ctrl-Alt-e. If this doesn't do anything immediately* then do the following: Switch back to X ...


0

PATH is usually set up in ${HOME}/.bashrc, the file yousource`d. To see which line, you could type: grep -n virtualenvwrapper ${HOME}/.bashrc Redo the step of the "tutorial for this on Ubuntu" (no actual link, and why should I go read it anyhow?) that had you entering the PATH, or edit ${HOME}/.bashrc yourself.


1

Using cat and awk cat ind_list | xargs -i'{}' awk '{print $3}' "{}.sites.pi" > output Example Input files cat OC8.sites.pi foo bar foobar cat OC9.sites.pi foo bar foobar cat Ocu27.sites.pi foobar foo bar cat ind_list OC8 OC9 Ocu27 The command cat ind_list | xargs -i'{}' awk '{print $3}' "{}.sites.pi" > output The output file cat ...


1

I don't have a terminal to test my answer, so I'll try a blind guess. I'd think there might be a difference in behaviour between paste <(cut -f3 Ocu27.sites.pi) <(cut -f3 OS10.sites.pi) >output and paste <(cut -f3 Ocu27.sites.pi) >>output paste <(cut -f3 OS10.sites.pi) >>output To address that, you could change your ...


2

Pasting files needs to have all the elements given at the same time to paste. Since you are reading a file, you then need to firstly store the content somewhere -in a temp file, for example- so that you can then paste them together. So I suggest something like this: i=1 while read -r file do awk '{print $3}' "$file" > file.$i ((i++)) done < ...


4

You probably need to run the script like: sudo /path/to/myScript sudo ./myScript (if the script is in the current directory) The reason you get command not found is the script is not in the current user's PATH directory. However, using sudo runs it as a different user - root (compare echo $PATH and sudo -i then echo $PATH to see). So of you want to add ...


0

This is more of a style criticism. A Best Practice is to quote strings that the shell should NOT expand with '', and strings that the shell should expand with "". Thus rather than: d1=$(date --date="-10 min" "+%b %_d %H:%M") Use d1="$(date --date='-10 min' '+%b %_d %H:%M')" Also, your find /var/log/mail.log | xargs grep "sent" | is more easily ...


2

You are using &> for redirecting both STDOUT and STDERR, which is a bashism. As the default shell for cron (not the same thing as your scripts shebang) is sh (which is dash in Ubuntu), it does not understand &> syntax. As a result it is treating the & to put the shell script as a background job. To overcome this, use the portable way of ...


-1

UPDATE- As waltinator says executing bash command right after ls command will create child shell which will probably eat up resources , I had to look for another solution. I tried executing echo -ne '\e[1;31m' light after ls command therefore I put it in the bls funciton. I somehow reached to my own solution to this problem. The suggestions by meuh and ...


8

Perhaps: while read ip rest_of_line; do ssh user@$ip sudo poweroff done < server.file The ssh command will return when the ssh daemon on the remote server is shut down. This is not when the machine is powered off. You might want to add a sleep command following the ssh command. Your user should be configured to do sudo poweroff without having to ...


2

save this as run_gedit.sh #!/bin/bash gedit & then run chmod 755 run_gedit.sh and you should be able to start it by clicking on the file.


0

Commands which set colours may finish by sending the sequence ESC [ 0 m to reset the current attributes for the terminal. The easiest thing for you to do is change your shell prompt to always set the colour back to what you want. Add to your .bash_profile: export PS1='\e[1;31m'"$PS1"


0

After installing nvm using the installation script approach, I had to source my .bachrc file: source ~/.bashrc Now the nvm command should work: me@computer:/$ nvm --version 0.26.0


2

Yes, what you are asking is possible. If this is your crontab command: * 10 * * * * doCommand * 10 * * * * gnome-terminal -e doCommand However, when the command finishes, the terminal will close. I think you need to create a log - rather than show the output in the terminal, redirect it to a file. Original command output: $ echo "This is the Command ...


1

You absolutely can use only one script instead of 3. For that, you could just pass arguments from the command line. In every bash scripts and functions, some variables called positional parameters are automatically generated. At the beginning of your script (i.e. when no other command has been executed yet), you will have : $0 : the name of the script $1 : ...


0

Bash doesn't interpret variables in single-quote strings. That's why that isn't working. myString="this/is_an?Example=String" sed -i "s|sourceString|${myString}destinationString|g" myTextFile.txt Would work. Or if you need the single-quote for another reason, you can just butt strings together and they'll be intepreted as one: ...


1

I would suggest defining multiple field separators (i.e. :, ,, and }) and then select the fields accordingly: awk 'BEGIN { FS = "[:,}]" } { print $3,$5,$6,$7 } '


1

What about removing everything not being a digit, a dot or a space? $ awk '{gsub(/[^0-9. ]/,"")}1' file 0.00030804 0 0.164494 1.00723 0.176236 0.31516 0.6876 1.00723 0.224808 0 0.813626 1.00723 Note however that parsing a JSON with awk is not a very good approach. You may want to use jq for this.


1

The real solution is to add stty columns 1000 Before PS1 (Work in debian) Thanks to Gennady for this good answer


-1

Try reinstalling ruby maybe? sudo apt-get install --reinstall ruby



Top 50 recent answers are included