Questions about bash only, as opposed to other Bourne/POSIX shells. For all Bourne/POSIX-style shells, use the /shell tag instead.

learn more… | top users | synonyms

0
votes
1answer
23 views

How to grab output from shell in shell script

I'm trying to write a shell script in rhel which will execute grub-md5-crypt and the user will type the password. Now the problem is how can I grab the encrypted md5 hash displayed to the user in the ...
1
vote
0answers
7 views

How do I execute a program in Xfce and make it use another xfwm4 theme other than the default one?

I want to run a python script (the one in the answer to Python - how to make transparent window with gtk.Window but not with Gtk.) that displays a transparent window. I'm running it from a bash script ...
0
votes
1answer
31 views

How to ssh into remote machine and create new user in bash script

I am writing a bash script and would like to ssh into a remote machine and execute the adduser command. This is not working, all that I get is the --help text for adduser when I run the code below. ...
0
votes
0answers
21 views

Opening a terminal other than xterm, running a command on it, and not closing the terminal after it succesfully finished

I have the following script in my arch linux box: #!/bin/bash xterm -e "sudo pacman -Syu;bash" This will fire up an xterm, and run the command sudo pacman -Syu on it. Because of the ;bash part, it ...
2
votes
1answer
60 views

Bash: Syntax Error on @()

I have the following function in my .bashrc file: extract() { local c e i (($#)) || return for i; do c='' e=1 if [[ ! -r $i ]]; then echo "$0: file ...
1
vote
2answers
54 views

Shell script throws a not found error when run from a sh file. But if entered manually the commands work

Im trying to use the following script to generate a sitemap for my website. When I run it as sh thsitemap.sh I get an error like this and creates an empty sitemap.xml file : thsitemap.sh: 22: ...
3
votes
1answer
43 views

How do I diff the outputs of two commands?

How can I use the diff command to compare 2 commands' outputs? Does something like this exist? diff ($cat /etc/passwd) ($cut -f2/etc/passwd)
0
votes
0answers
46 views

How to match this regular expression in bash? [on hold]

I'm trying to match the sub string "~goddog" in the string "sort -u ~goddog/classes". I've defined two variables as below: cmd="sort -u ~goddog/classes" #eid="gogdog" eid="goddog" The following ...
0
votes
1answer
28 views

Trying to access environment variable (array) declared in ~/.profile from shell script

I'm currently fighting with this problem. I've already read some older posts here on SE, and got the conclusion that the only sane way to put a variable (even an array) is ~/.profile. So OK, array ...
2
votes
1answer
12 views

bash_completion does not work in dtach

I start dtach from bash using the following command dtach -c /tmp/dt0 bash the problem is, before I started dtach, bash_completion worked. But once I start dtach, bash_completion does not work ...
0
votes
2answers
41 views

how to create Permanent alias from script

Please advice how to do the following magic ( I have linux red-hat machine – 5.4 ) I created the script in the following path: /usr/cti/my_scripts/MAGIC.bash I want to run this script ...
1
vote
1answer
69 views

What is happening while executing this command cd / | vi?

When I execute the command cd / | vi, it goes to the vi editor. When I type any command it does not display the command but it gets executed and the command that is executed is not shown in the ...
0
votes
4answers
55 views

Use SED or AWK to move rows to columns

I have a report that is generated in rows and I need to move it to columns. The number of rows per record will always be the same. This will be in a BASH script on Linux, so I would like to use ...
1
vote
1answer
18 views

how to recall last argument in bash with vi setting

I use set -o vi setting in bash. The shorcut Alt+. (recalling last argument of previous command) here doesn't work as in emacs mode, so what is the equivalent for vi?
0
votes
0answers
27 views

How to achieve a good format in json? [on hold]

I been posting this question in other stackexchange site but I haven't receive a good solution yet for this problem in getting a good format or output in json. ...
3
votes
2answers
203 views

Brace expansion does not work for less than 2 arguments

I was expecting brace expansion to work for any number of arguments. However, for n=1 I get the following: $ find models/nsf-projects-{7}* models/nsf-projects-{7}.rdf For n>1 expansion occurs as ...
4
votes
1answer
225 views

Bash: Variable assignment doesn't seem to 'stick' [duplicate]

I am having a hard time tracking down the reason my 'boolean' flag variable won't stay false when a test fails inside a while loop. The script involves a few loops but essentially it is intended to ...
17
votes
6answers
1k views

How to debug a bash script?

I'm having some problems with some scripts in bash, about errors and unexpected behaviors. I would like to investigate the causes of the problems so I can apply fixes. Is there a way I can turn some ...
0
votes
0answers
50 views

What is the difference between double quotes (“”) and single quotes ('')? [duplicate]

I really do not know the usage of " and '. I want to know usage of " and '. What is the difference between echo "hi" and echo 'hi'.
0
votes
1answer
27 views

How to call a bash script from another script?

I know there is many similar questions but I was not able to find an answer for mine: I have couple of if and checking to get to this point of source script to call another script source ./call.sh ...
2
votes
1answer
61 views

Match empty line in an alias .bashrc

I would like to bind my empty line in my bash to a specific command (for example pwd, ls, ...), like so : $<enter> $/home/ I tried // ~/.bashrc alias ="pwd" But obviously this was ...
3
votes
3answers
184 views

Method for storing/remembering one liner commands

Often when configuring and adjusting unix-based systems I use a lot of one-line commands that are difficult to remember. For example, to determine what version of ntp (the time server) is running, you ...
1
vote
1answer
50 views

.bashrc and .bash_profile not executed [on hold]

I'm running RHEL5. I added simple alias command into ~/.bashrc. When I start a new terminal, nothing happens but source ~/.bashrc works so I know the syntax is correct. I also ...
3
votes
1answer
44 views

Extract csv files from path to multiple files in bash

I have a files multiple file path for backup purpose ,now i want to filter it based on ".csv " fromat. I have tried this. filesall=(/home/abc/allfiles/*) files=$((${filesall[@]}|grep -F ".csv")) ...
1
vote
3answers
73 views

How to use a variable plus glob ($var*) in bash

I'm having a issue with a script. So this is the code #!/bin/bash date=`date +"%m-%d-%y"` dokuwiki="dokuwiki.$date*.toolbox.admin.tar.gz" if test -e $dokuwiki then echo "works" else echo "shits ...
0
votes
1answer
40 views

Got “syntax error near unexpected end of file” in bash script

I'm making an script that gives me a day like this jjj/yyyy when I give it a day like this dd/mm/yyyy and I need it to have an error when you don't write correctly but I'm starting and it's not ...
1
vote
1answer
41 views

Store output from one command and process it for another

I am working on Unix command line. I have two files. I want to cat file1.txt and grep the output in file2.txt File1.txt 123A 223A 143A 153A 183A 123J 123P File2.txt: 123A (TYU) 223A (RUT) 143A ...
8
votes
4answers
211 views

How to assign space-containing values to variables in bash using eval

I want to dynamically assign values to variables using eval. The following dummy example works: var_name="fruit" var_value="orange" eval $(echo $var_name=$var_value) echo $fruit orange However, ...
2
votes
2answers
45 views

Fetching individual bytes from a binary file into a variable with bash

I need to make a fairly simple bash script to pull bytes one at a time from a binary file, send it out a serial port, and then wait for a byte to come back before I send the next one. This is ...
3
votes
1answer
322 views

while using '$?' expression in bash script

I'm writing a simple bash script #!/bin/bash ls xyzzy.345 > /dev/null 2>&1 status =' echo $?' echo "status is $status" which finds the file xyzzy.345 and logs the result to /dev/null. ...
1
vote
0answers
59 views

bash: /etc/bash.bashrc: Permission denied whenever I open a terminal

On Ubuntu 13.10, when I open a new terminal, I sometimes get the following output on the terminal: bash: /etc/bash.bashrc: Permission denied However, the permissions should be fine: >ls -l ...
1
vote
1answer
32 views

Hide make targets from shell when users autocomplete in bash

Is there a way to flag some targets in a Makefile so that they don't appear at all in the shell when the user types make and then presses Tab ? I am having a Makefile with too many recipes and I don't ...
4
votes
2answers
74 views

How can I force bash to deallocate a brace expanded variable without name?

For benchmarking, I ran the command: for i in {1..100000000}; do echo "$i" line >> file done Bash expanded the braces and stored the list 1 2 3 4 5 6 ... 100000000 in memory. I thought ...
3
votes
0answers
41 views

How to stop bash editing the history when I reuse and modify an entry?

Some instances of bash change the command history when you re-use and edit a previous command, others apparently don't. I've been searching and searching but can't find anything that says how to ...
12
votes
3answers
2k views

Why does [a-z] asterisk match numbers?

I have 3 directories at current path. $ls a_0db_data a_clean_0db_data a_clean_data $ls a_*_data a_0db_data: a_clean_0db_data: a_clean_data: $ls a_[a-z]*_data a_clean_0db_data: a_clean_data: I ...
0
votes
0answers
30 views

How to get the value in a file? [closed]

I would like to ask how to get the 4th to the last value in a file. I don't have problem on extracting a value from the beginning of the file using sed (e.g. sed -n '4p' filename.txt) only have a ...
1
vote
4answers
49 views

variable assignment from inside a bash script

This is obviously an SSCCE, so it makes (in itself) no sense. E.g. the variable assignment to Y is not used in this minimal example; I'm just trying to figure out the correct syntax to use for my ...
2
votes
3answers
46 views

Repeat Last N commands [duplicate]

In bash, I tried writing a script to run the last N commands. For say, N=5 for i in {1...5} do !-5 done The problem is that !-5 gets replaced by the 5th-last command on my shell (say time) and ...
4
votes
2answers
55 views

Shell script error handling while assigning STDOUT to variable

I am trying to implement error handling in my shell script as described in the 2nd answer in Best practice to use $? in bash? My script looks like this: #!/bin/bash try() { "$@" code=$? ...
3
votes
2answers
49 views

Go up one level from a nonexistent path

I have some code like this in a script (bash) file: if [ ! -d $dir ]; then cd $dir/.. git clone http://... fi Of course as written this doesn't work since $dir does not exist. Is there a ...
2
votes
1answer
16 views

WinRAR installer.rar situation (automating expect install)

I'm writing a script that should set up a server with no user input. Whatsoever. In order to automate installation of some programs, I used expect. However, what can I use to automate expect ...
0
votes
0answers
20 views

What does !$ mean exactly? [duplicate]

echo !$ outputs different strings depending on my previous command line call. For example: mrdumbdumb-redhat:~ mrdumbdumb$ ls mrdumbdumb-redhat:~ mrdumbdumb$ echo !$ echo ls ls ...
4
votes
3answers
185 views

How to call a service URL from bash shell script in parallel?

I have a service which I am calling from another application. Below is my service URL which I am calling - http://www.betaservice.domain.host.com/web/hasChanged?ver=0 I need to do some load test ...
2
votes
1answer
30 views

Installing noip via sh script

I have this script: cd /usr/local/src/ wget http://www.no-ip.com/client/linux/noip-duc-linux.tar.gz tar xf noip-duc-linux.tar.gz cd noip-2.1.9-1/ make install <<END_SCRIPT Username password ...
2
votes
1answer
21 views

unexpected EOF while looking for matching `"' - bash script

I just wrote a bash script (im a Newbie to shell-scripting ;) ) and always getting this EOF-Error. So here is my script (only works on OS X): #!/bin/bash #DEFINITIONS BEGIN en_sq() { echo -e ...
1
vote
3answers
228 views

“Can't cd to /home/user” when sourcing a script

I have this script: echo $HOME cd $HOME cd / cd /usr/local/src/ When I run it like this . script.sh I get this output: /home/user : No such file or directory : No such file or directory : No ...
1
vote
4answers
48 views

How to have service that makes sure program keeps running?

I made a service called thin_keep_alive_service in /etc/init.d. I gave it chmod +x rights. The script looks as follows: #!/bin/bash ### BEGIN INIT INFO # Provides: thin_keep_alive_service # ...
1
vote
2answers
49 views

Run command on startup for one user

I made a new user on my server. The user is not logged into the bash shell on startup. To do this I can run /bin/bash --login and it works. Where do I place this command so that it runs ...
1
vote
2answers
35 views

Double click Linux Bash Script and debug with pause commands

I'm fairly good with windows .bat scripts and normally use the pause command while developing them so I can see things step by step as the script runs in the command prompt. I am trying to do ...
8
votes
4answers
752 views

Can I reference a command before '&&' after '&&'

Not sure how else to phrase the question, but basically, I often find myself running a command like vagrant to bring up the VM, and then ssh into it like below: vagrant up && vagrant ssh ...