Bash is the shell used in Ubuntu's command-line interface.

learn more… | top users | synonyms (1)

1
vote
1answer
6 views

Run multiple line as a single line command bash

Is there any way to run multiple line as a single line command in bash script. This is my multiple line bash script id=15; if [ $id -ge 30 ] then echo Successful echo $id else echo fail echo $id fi ...
0
votes
3answers
18 views

How can I know which file is being used in a bash for loop?

I have a very tricky question that I have been wanting to tackle for quite some time. If $line is from $(cat foo), then do action1 If $line is from $(cat bar), then do action2 for line in $(cat ...
13
votes
1answer
639 views

opposite of eject command?

I have a ton of CDs to image, and I just got curious. I can eject with the eject command. What command inserts the disk tray back into the CD drive? yes it is the type that can pull the tray back in. ...
1
vote
1answer
13 views

Script to generate thumbs only if thumb doesn't exist

I have a working script to generate thumbs to all pdf files in a folder( using Image Magic): for f in *.pdf; do convert -thumbnail 250x200 "$f"[0]"_thumb_wd_${f%.pdf}.jpg"; done How can i adjust ...
2
votes
3answers
149 views

Creating a folder based on a portion of a file name

I have several files named such: KILN_SDUS51_N0SILN_201203020003 KILN_SDUS51_N0QILN_201203020003 KILN_SDUS51_N0RILN_201203020003 I need to file all of them into folders based on the three ...
3
votes
2answers
99 views

How move the biggest file in each subdirectory to current directory?

I like to loop though subdirectories and more the biggest file to its parent and then delete the folder. I have tried many things but never got it working correctly. It says that mv cant find the ...
2
votes
1answer
16 views

antlr4 alias not persisting

I'm trying to set up Antlr 4.5 as per the instructions here but the alias isn't accessible from where I've put my project after a reboot, which makes me wonder if I've done the classpath step ...
1
vote
2answers
162 views

split large file in bash

How can I pass all files in a list.txt which looks like file1_1.txt file1_2.txt file1_3.txt file1_4.txt to the split command (there are other txt files in the dir) and make it return the parts ...
1
vote
1answer
43 views

script sh syntax error

I have this script: #!/bin/bash IP='192.168.1.1' fping -c1 -t300 $IP 2>/dev/null 1>/dev/null if [ "$?" = 0 ] then echo "Host found" else echo "Host not found" fi When I try to run it, ...
1
vote
2answers
71 views

Shell script does not run when I double click

I have made a shell script (test.sh) on my Lubuntu (15.04) desktop. Permissions are: Only owner (View content + Change content + Execute). When I double click test.sh, I choose "Execute in Terminal". ...
2
votes
4answers
304 views

Bash script to rename files in a directory

I am trying to write a script that takes a directory as a command line parameter and iterates over the files in the directory changing their extension to .bu . I thought this would work but I'm ...
1
vote
1answer
28 views

cannot change directory with script [duplicate]

I tried the following script to give myself convenience in changing directories to different hard disk partitions. But after its execution, the default location does not change, but if I use command ...
1
vote
0answers
18 views

Terminal Closes On Running clear and large output commands

When I run the clear command or ctrl+L or commands with large output like ps aux, my terminal closes. I have set the scrollback to unlimited.
16
votes
9answers
1k views
+100

Desktop notification when long running commands complete

I'd like to have a desktop notification whenever a command that has run for more than, say 15 seconds, finishes. In other words, I would like all commands to be wrapped in something like this ...
3
votes
2answers
54 views

Ctrl+C command is not terminating infinite (while) loop

I have this little script. When I start it and the terminal has the focus Ctrl+C stops feh and then the while loop starts feh again. I am expecting that, as long as the terminal(!) has the focus, ...
5
votes
8answers
481 views

How can I delete text that is NOT in quotes or parentheses?

Input: 19. "foo foo" (bar bar) (19) raboof "foo foo" raboof Expected output: "foo foo" (bar bar) (19) "foo foo" As you can see, I would like to keep the double quotes and parentheses. ...
0
votes
0answers
21 views

Xinput command in autorun script doesn't execute

I use two monitors 15 inch and 19 inch. With the 15 inch I also use a touchscreen. I have to map touch events to 15 inch monitor with this command: xinput map-to-output 11 VGA1 11 stands for id ...
1
vote
2answers
39 views

error while cron scheduling a sh script

This is my shell script which i want to schedule using cron job. parser.sh #!/bin/bash source .profile workon venv cd /home/ashish/deployments/myproject export ...
16
votes
2answers
4k views

Can I enable bash-completion for the new apt command?

The new apt command, present in Ubuntu since 14.04, seems to be a really useful intersection of functionality between apt-get and apt-cache but the current version of bash-completion doesn't know ...
0
votes
3answers
28 views

How to Verify JAVA_HOME path

I installed java in opt/jdk1.7.75 having following directories--> bin db include jre lib man COPYRIGHT LICENSE README.html relase & other files I set JAVA_HOME path in .bashrc file as follow: ...
2
votes
3answers
152 views

Regex Conversion

I'm wanting to make a command to edit /etc/default/grub and change the timeout from 10 to 2. Could anyone explain how to do this?
0
votes
3answers
66 views

How to Keep Text Consistent in A Shell Script

Good Day! I am creating a Shell Script so I can then use it to do X (Won't tell) This is my Current Script clear echo Ahmad A Kazi echo IDNO: BD_3456 echo echo Data Clear Program echo c 2015 Ahmad ...
5
votes
5answers
565 views

What can I do in order to change the “.33” value into “0.33”?

I want to compare the value against 0 and it tells me that it is less than 0. I used solution=`echo $a / $b | bc -l` This issue occurs only when "a" is less than "b".
1
vote
1answer
44 views

Customize Colors for Bash Terminal

I found this nice color library called Solarize which promises to liven up my hacking experience with a color terminal. I am not where to add the Solarize files to change. I found some ...
1
vote
1answer
25 views

How to create log file from a command (through alias)

The call is simply ud typed in a terminal. ud is defined as the following in my ~/.bash_aliases: alias ud='sudo apt-get update && sudo apt-get upgrade -y && sudo apt-get dist-upgrade ...
3
votes
2answers
69 views

bash: script/bash_completion_dog: No such file or directory

When I open my terminal, I get this message. I tried to correct my .bashrc file but could not find anything related to this error message. How do I resolve this? As suggested by terdon, I tried the ...
1
vote
1answer
28 views

Where is the manpage of the set builtin? [duplicate]

When I type the command man set It gives the postgresql 9.3.6 manpage documentation of the set command. (May be I need to precise that I have postgres installed in my machine). However, I am not ...
5
votes
1answer
72 views

How to make reverse-i-search in terminal easier using comments?

When you press Ctrl+r in terminal this leads to use the reverse-incremental-search mode. The reverse-i-search lets you search for previous commands in your terminal, but this can get confusing when ...
63
votes
5answers
45k views

Which one is better: using ; or && to execute multiple commands in one line?

In tutorials and how-to's I often see commands combined. For instance, sudo apt-get update && sudo apt-get install pyrenamer There seem to be four possible connectors: &, &&, || ...
10
votes
4answers
295 views

How can I merge files on a line by line basis?

cat file1 foo ice two cat file2 bar cream hundred Desired output: foobar icecream twohundred I already have a solution involving a for loop with sed using the line number of the files, but in ...
21
votes
1answer
15k views

Bash: delete word ahead of cursor

Consider the following bash prompt, where ^ denotes the prompt location: svn commit -m very/long/path/to/some/file "[bug 123456] Fix the pixel issue" ^ I'd like to commit a different ...
4
votes
4answers
143 views

How can I extract text between parentheses containing a specific word?

How can I convert this: foo (blah) (bar 80) foo (cats) (blat 92) To this: foo bar 80 foo blat 92 I would like to keep all the text that is NOT in parentheses. I only want to extract text ...
24
votes
2answers
22k views

Reload bash's .profile without logging out and back in again

Is it possible to coerce bash to reload the .profile file without logging out and back in again?
2
votes
1answer
24 views

Gnome-terminal not working properly with screen-256colors

Today I noticed I did not have 256 color support in Weechat. I decided this would be a quick fix. It isn't. First thing I googled was how to test the color support in terminal. I have installed ...
5
votes
3answers
874 views

Why is this bypassing the SUDO password?

I have a bash script I am using to automate a SVN checkout. The contents of the file were: #!/bin/bash cd /var/www-cake sudo svn checkout file:///usr/local/svn/bash_repo/repo/ Then when I double ...
2
votes
3answers
399 views

What other bash variables are available during execution such as $USER that can assist on my script?

This is related to question Why is this bypassing the SUDO password?. In that one of the responders answered the question in an awesome way, and very, very clear to any newbie. Now here is a question ...
6
votes
2answers
12k views

What does outputting to /dev/null accomplish in bash scripts?

Oftentimes I run into small bash scripts that use this sort of syntax in if statements: some command > /dev/null 2>&1 What is the purpose of outputting to /dev/null like that, and what does the ...
5
votes
1answer
240 views

Getting the default text editor used in system

I have been searching and browsing for a long time and have not been able to find an answer to my question. I have used select-editor and I note that I am using /usr/bin/nano. Is this the default ...
4
votes
4answers
4k views

segmentation fault when using su or sudo

example of the problem: $ su Segmentation fault $ sudo ls Segmentation fault I tried to compile sqlite3 from source earlier. I don't know what libraries it installed. This may be the reason why ...
0
votes
3answers
49 views

How to create desktop shortcut to bash program running java

I've downloaded the free and open-source image analysis software "Icy" (http://icy.bioimageanalysis.org/), and I can launch it by making the "icy.sh" file executable and double-clicking on it. ...
0
votes
3answers
95 views

listing permissions

I'm a biomedical scientist and I'm having trouble running a custom data analysis pipeline written by one of our collaborators. His script crashes with /bin/sh: 1: ...
1
vote
1answer
34 views

How can I list mp3 files that have a leading period?

I have mp3 files in a directory. For this example, let's assume they are these 3: Enter Sandman.mp3 ...And Justice For All.mp3 St. Anger.mp3 How can I list (ls is highly preferred) all ...
0
votes
2answers
27 views

aliases not picked up when sudo in mac? [on hold]

I have the following aliases in /etc/profile. # System-wide .profile for sh(1) if [ -x /usr/libexec/path_helper ]; then eval `/usr/libexec/path_helper -s` fi if [ "${BASH-no}" != "no" ]; ...
15
votes
8answers
31k views

How do I rebuild a corrupt dpkg status file?

Whenever I type sudo apt-get remove and then press the Tab key for auto-completion I get the following message: grep-status: /var/lib/dpkg/status:15945: expected a colon . I don't see anything ...
4
votes
2answers
54 views

useradd doesn't allow the user to log on

On an Ubuntu 14.04.2 LTS the following command: adduser fu and then entering a password bar and just pressing Enter on all other questions, creates a user that allows me to log on and has the ...
2
votes
4answers
8k views

ping multiple IP's using bash?

I have 10 IP numbers which I have to ping daily for checking , How I can do that by using BASH script. So that I can automate that task by using cron. I want BASH script only. Thank you.
7
votes
3answers
114 views

How to run a script when a directory is changed by another user?

I know has been a bit of discussion about topics similar to this. But here is what I am basically trying to do. I have a watch directory called watched and whenever a file is added to that directory, ...
-2
votes
1answer
18 views

Zenity is not displaying the GUI results in the bash script. The same script is displaying results successfully in Redhat [closed]

ALERT=10 df -h|grep -i dev|grep -vE '^Filesystem|proc|none|tmpfs|udev' |awk '{print $1 " " $5 " " $6}' |while read output do partition=$(echo $output | awk '{print $1}') usage=$(echo $output | ...
24
votes
3answers
2k views

“mv file” and now it's missing

In a terminal window, I typed: mv filename ..\.. [Note the wrong slash.] Now I can't find it. Gone. I ran some searches and looked through recoverable deleted files. Nothing. Poof. Serves me ...
1
vote
2answers
107 views

bash: ./name.exe: Permission denied

I want to execute a program in Ubuntu 12.04...but when I type ./programname.exe it makes error: bash: ./gbat.exe: Permission denied and I typed "chmod +x programname.exe" , but it doesn't fix ...