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

learn more… | top users | synonyms (1)

4
votes
1answer
151 views

Writing a program that will demo the $PS2 variable

I've been customizing my terminal prompt, and found that it's possible to change the "secondary prompt". However, I have no way to test the changes I make to this one so I was wondering if a simple ...
1
vote
2answers
64 views

Running a command in screen daemon mode

I am trying to run a command in screen mode using the command screen -dmS screen_name sed -i 's/a/b/'g some-file.txt Nothing happens. When I put the same command in a script and run the command: ...
1
vote
2answers
36 views

Rsync --delete option doesn't delete files in target directory

I'm trying to use the --delete option in rsync to delete files in the target directory which isn't present in the original directory Here is the command I'm using: rsync -avz --ignore-existing ...
5
votes
4answers
359 views

Get previous commands in Terminal that match the currently typed command [duplicate]

In some terminals you can do something like this... Type some command nmap -sn 192.168.1.1/24 Then go on to do other things in the terminal for a while. Then later you can type nmap and then ...
1
vote
1answer
42 views

Different shells on SSH and local

So I've got an Ubuntu 14.04.2 computer that has OpenSSH Server installed on it. Whenever I use the computer locally, through the terminal, if I run: ~$ echo $SHELL /bin/bash However, if I SSH into ...
1
vote
3answers
46 views

What does this egrep command do?

I run this command egrep "\" string_demo | wc -l I got output below: akshay@akshay-K53SC:~/shell$ egrep "\" string_demo | wc -l > abc > pqr > xyz > ">" will continue until I press ...
0
votes
0answers
13 views

purpose of bamf-2.index [duplicate]

What is the purpose of /usr/share/applications/bamf-2.index ? I have noticed the applications it contains are installed in my computer. But I don't think it contains the complete list. Because the ...
0
votes
2answers
95 views

Enforce a shell script to execute a specific python version

Update. Changing the alias unfortunately does not work. I have changed the alias to alias python='/usr/bin/python2.7' however the shell script still runs the python script in 2.4.3. Muru - I am ...
1
vote
1answer
103 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 ...
2
votes
3answers
165 views

Error when running script in bash

I wrote a script in bash to basically create aliases, but for any reason, it doesn't work in some cases. Here it's the code: #!/bin/bash #Script to create unique and permanent aliases _add_alias() { ...
1
vote
1answer
54 views

How to remove all lines in a file containing a string from another file

I want to remove all lines in a file containing a string from another file. So I don't want to remove the lines which are identical, there are none, but remove all lines if they share a string from ...
5
votes
3answers
247 views

Count down script is not working

I am trying to create a script that will count down to 0 from what ever number I give it. Below is my script and basically nothing happens, no error message, I merely get the standard command line ...
1
vote
0answers
25 views

speech-dispatcher always stop working after terminal exit?

In a previous question I made this line: trap 'clear; ~/ascii3.sh; spd-say "Exit"; sleep 2' EXIT The content of ascii3.sh is: echo -e "\033[01;31m" echo " _ _ __ _ _ ____ __ __ _ ...
-1
votes
1answer
28 views

How to stop renaming a file which was already renamed using loop in shell script

I have a directory name dir1 containing another directories named 1,2,3,4,5. Now I want to rename directory 1 with 4, 2 => 5, 3 => 6, 4 => 5. but my problem is using mv command in shell script ...
1
vote
1answer
22 views

heredoc variables between underscores

Say I have something like this, tee filename <<EOF ... access_log /srv/users/serverpilot/log/$APP_NAME/$APP_NAME_nginx.access.log main; ... EOF where $APP_NAME is a variable. Bash ...
2
votes
1answer
44 views

sed to execute a command as replacement with substitution pattern as argument

I am trying to replace time in a log file by: cat mlog.log | sed -e "s/^[0-9\.]*/\$(date -d @&)/" Why it always first execute $(date -d $&) but not doing replacement at first and then ...
1
vote
1answer
69 views

USB mouse on Ubuntu stops working [duplicate]

Many times my mouse USB suddenly stops working, though the trackpad works just fine. I have to click it to make it work again. I have found the following solution: sudo bash for i in ...
0
votes
0answers
42 views

Running a bash script on “Switch User”?

I've had my first dabble with bash and got a working script going for each user on session start which checks if a NAS share is mounted and if it is unmounts it and mounts as the current user. This ...
1
vote
3answers
49 views

Force “bad” (not 0) return code of terminal command?

I have a framework written in python, and for testing purposes I basically want to do a subprocess (aka shell call) ... that should simply come back with a RC != 0. I tried to invoke some non-existing ...
2
votes
3answers
155 views

How to run a bash script after 20 sec on Login?

I want to run a bash script like: #!/bin/bash echo 'cpu limit bomi player at 40%' cpulimit -v -e bomi -l 40 Just 20 seconds after Login into my user. Can you please help me to do that? ...
2
votes
2answers
42 views

Timing limiter for execution of commands in Bash/Shell Script

I have a shell script which looks like this: echo firstOutput read -s command0 command1a command1b command1c echo secondOutput command2 command1a, command1b, command1c are individual commands but ...
0
votes
1answer
27 views

Create an alias for a directory while working in virtual environment

I've checked this. But right now I'm working in a virtual env. cam@cam:~$ cd Desktop/django-user3 cam@cam:~/Desktop/django-user3$ source newenv/bin/activate (newenv)cam@cam:~/Desktop/django-user3$ ...
13
votes
1answer
648 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. ...
4
votes
3answers
279 views

improve bash script

I have a quad core desktop, and i wanted to know the average temprature according to sensors. so i wrote this bash 1 liner. echo `sensors -A | awk {'print $3'} | sed 's/+\|(crit\|0:\|°C//g'` | awk ...
-2
votes
4answers
60 views

Why am I getting a syntax error in this script?

When running the script below, I get an error: The script is: clear echo "Enter a num" read num if [ "$num" -ge 0]; then f=1 i=1 while [ $i -le "$num" ]; do f=`expr $f \* $i` ...
7
votes
3answers
336 views

How do I search shell command history with a text editor?

I know that Ctrl+R let's you search command history, but it's a little primitive. Is there a way to export all my command history (not just the current terminal session, but the full history) to a ...
2
votes
1answer
113 views

I see one backslash, but there are actually two backslashes!

Does anyone can help me to understand that weird issue? I was trying to rename a very long list of folders. I went to the parent directory and listed all the folders to rename in a text file: find ...
1
vote
1answer
39 views

Why is this odd file extension appearing when I scp a file?

I'm creating a large number of gifs and copying them to a separate computer with a webserver folder mounted via sshfs. For some reason the files will randomly copy with *.gif.001 file extensions. My ...
3
votes
1answer
47 views

Is there a bash/terminal command that will clear content prior to the last command?

Use case: I'm working in bash/terminal and have been typing several commands and I've just run something and it's spewed some output. I'm trying to find where that output started and have to visually ...
0
votes
1answer
29 views

how to stop using export command

every time I run gdb I have to type export SHELL=/bin/bash or gdb would return exit with code 127 my question how to make this command run every time automatically without need to re type it because ...
3
votes
1answer
56 views

Create zip files in /var/www/html using crontabs

As the title explains, I'd need to take a file and put it into a zip archive once a day; also, the zip file has to be moved in /var/www/html, where a .php scripts allow users to download it. Assuming ...
2
votes
2answers
134 views

Bash Script does not work?

I made a script to check if sdb or sdc drives are present. but even when I have both or one of them present the script is terminating. what is wrong with my script? HDD1="sdb" HDD2="sdc" echo ...
1
vote
0answers
73 views

Bash script: command not found

I have an executable script install_packages.sh in /home/etienne/admin folder. The directory's path is added to $PATH variable from /etc/bash.bashrc. When I type #echo $PATH I see that the variable ...
0
votes
2answers
30 views

Copy pictures recursively from one folder to the root of another?

So, I have a Windows virtual machine running this certain program. The details are as follows: The program has no recursive search functionality. I have lots of free disk space. I have excess junk ...
0
votes
2answers
25 views

Run command when CPU becomes free? [duplicate]

I have a PC with 4 CPUs that is running four jobs. I would like to run another job on it, but only when one of the CPUs becomes available. Is there simple command to do this (I know this is what ...
31
votes
4answers
2k views

When to use () vs. {} in bash?

I'm studying shell scripting with bash and I need to know the difference between (...) and {...}. How does one select between the two when writing a script?
0
votes
1answer
52 views

Creating new user, how to run commands after SSH login? (Ubuntu Server Trusty)

I have configured Ubuntu Server for my needs, and basically everything is working as I want. I'm new to Linux, but learned a lot using and interpreting different guides, however, this particular ...
0
votes
2answers
47 views

when ssh is run with a server + command argument, what startup profile runs if any?

I know /etc/profile and ~/.profile are among the start-up scripts used when ssh is used to login to a server – i. e. using ssh with server argument. However, the scenario where I am just using ssh ...
1
vote
1answer
240 views

Bashscript making a variable equal a command. error command not found

Hi i keep getting the error ./imagehash.sh: line 2: =: command not found When i know that i set the $CMD variable correctly (i tried the command outside the bash script and it worked just fine) ...
1
vote
1answer
13 views

Start gnome-terminal with predefined history

I would like to start a Gnome terminal window with a predefined history file. I tried: gnome-terminal -e 'bash -c "history -c; history -r ~/test.hist; exec bash"' but it still uses the standard ...
1
vote
2answers
37 views

wget: automatically overwrite dowloaded file create time to current?

When I download file using wget it copies create time from original file on server by default: > wget https://pbs.twimg.com/media/ByEt7bVIQAAzDVq.jpg > ls -l ByEt7bVIQAAzDVq.jpg -rw------- 1 ...
2
votes
2answers
156 views

cp problems with copying root

I have a little bash script going to check if the system has been backed up today and and if it hasn't then it copies the entire filesystem into the backups folder: date=$(date +"%m%d%y") sudo mkdir ...
3
votes
4answers
257 views

What is a practical way to list every character used in a file (Bash) (Regex)

How can I turn this: Johnny's penguin, (Tuxie), likes the following foods: French fries, and beef. To this: abcdefghiklnoprstuwFJT',():. (These are the total characters used in the input) ...
1
vote
1answer
31 views

New shell terminal points to different bash_profile [closed]

When I launch new terminal it points to some different bash profile. Here in my $PATH are set to default, $JAVA_HOME is blank When I source my .bashrc and and .bash_profile located at home then I am ...
1
vote
0answers
62 views

Connecting Ubuntu to Windows Domain

I made a bash script to automatically connect Ubuntu computers to a domain using PBIS Open. The script works and connects computers to the domain just fine almost every time. After awhile though, a ...
0
votes
2answers
45 views

Can i make a commad execute in background without producing any output?

Is there a way or an option to make a command run in the background without the need to wait for it to end to get the prompt back? (just like mplayer command to play a music file in the background and ...
2
votes
3answers
103 views

Can i edit a bash shell command?

I just wants to modify a bash shell command like exit so when i write exit in the terminal it clears the screen, and echo some text, wait 2 seconds, then execute the exit function. So is there any way ...
0
votes
2answers
34 views

Create a dir on scratch with same name as in pwd directory

HI I try to simplify my problem, I'm trying to write a bash script, which can take the actual directory name (just like you get by statement "basename" ) and create a same directory on scratch. ...
0
votes
1answer
62 views

How can I split a line in 2 by words/characters? (Bash) (Regex)

I would like to convert: Hello Hello Hi Hello Hello Hi Hi Hi Hi Hello To: Hello Hello Hi Hello Hello Hi Hi Hi Hi Hello I want to split a single line in 2, by having them have the closest amount ...
0
votes
3answers
77 views

How to add executable bash script on ubuntu startup

I have created a executable bash script (using chmod +x) for monitoring my system and it works perfectly with out any error. Now i want to add this script on my start up in order to executing the ...