Questions specific to GNU’s Bourne Again SHell, as opposed to other Bourne/POSIX shells. For questions about Unix shells in general, use the /shell tag instead.
0
votes
2answers
18 views
How can I preserve an environment variable across login shells?
I export LC_ALL="en_US.UTF-8" (via sendEnv in ssh_config) when using ssh to remote systems. When I su - user123 this variable is reset by the login shell. Is there a way to preserve this variable (as ...
0
votes
0answers
17 views
How to have a bash alias set from a random directory?
The alias itself does not need to be local to that directory, but I want to be able to set a bash alias from anywhere.
Consider this scenario:
I have a development directory ~/dev, in this ...
1
vote
2answers
20 views
Bash perform variable expansion of string
I'm trying to have two layers of indirection, though let me know if I'm a victim of the XY problem
Boiled Down Explanation of What I'd Like to Achieve
> test1=\$test2
> test2="string to print"
...
0
votes
1answer
35 views
Redirect grep error output inside if conditional
I have written a script to search an .ini file for some specific word.
The .ini file has one of two different names, (let's say config.ini or configuration.ini), so I have to check in both.
I am ...
1
vote
0answers
24 views
bash history truncated to 2000 at new login after upgrade to ubuntu 16.04
Ubuntu 14.04 with this setup worked fine .
Recently re installed my laptop with ubuntu 16.04 and every time I create a new terminal , the history get truncated to 2000 lines.
I use both Tilda and ...
0
votes
1answer
37 views
iterate script execution: A call B, B call A
I have a script scriptA.sh that if a variable assume a certain value, it has to execute another script scriptB.sh that execute something and then call a scriptA.sh, that will call a scriptB.sh and so ...
0
votes
1answer
37 views
How to get exit status of a background process?
I am running two mysqlsp in a bash script. I want to start both of them simultaneously (they are running in remote servers) and put them in background, once completed proceed to next step. I want to ...
0
votes
0answers
20 views
How to understand the diffrent order of redirections means? [duplicate]
In the Bash Reference Manual:
Note that the order of redirections is significant. For example, the
command
ls > dirlist 2>&1 directs both standard output (file descriptor 1) and
...
5
votes
1answer
273 views
Does bash have different weak quoting rules for special variables?
I don't think I fully understand the nuances of quoting in bash.
I have a script, foo.sh, which simply outputs numbered arguments.
#!/bin/bash
i=1
while [ $i -le $# ] ; do
v=$(eval "echo \$$i")
...
-2
votes
3answers
26 views
Problem using sed substitution command inside -exec option of find
Input 1:
find . -maxdepth 1 -name "* *" -exec bash -c 'sed -n '1p' <(echo $1)' h {} \;
Output 1:
./file with space
Input 2:
find . -maxdepth 1 -name "* *" -exec bash -c 'sed "1s_ _._" <(...
0
votes
2answers
28 views
How can I skip --MORE— option when I tab in cd?
I wrote in terminal:
cd /some_path/
then I pressed tab and if there are a lot of directories in some_path I saw a terminal with a lot of lines and at the end there is "--MORE--" option.
I should ...
0
votes
3answers
36 views
Writing and reading from file descriptor 3 and /proc
When I run the following command:
exec 3<<< "TEST"
I can see the following appear in /proc (note last line regarding FD3 reading deleted):
# ls -al /proc/$$/fd
total 0
dr-x------ 2 root ...
3
votes
2answers
65 views
Bash assign output/error to variable
I have the following line in my bash file:
LIST=$(ssh 192.168.0.22 'ls -1 /web');
The problem I am having is that it is a part of automated script and I often get this on the stdout and not the data ...
0
votes
0answers
17 views
Running total after a while loop [duplicate]
I am trying to calculate the running total for RSS and SZ from the "ps -ly" command. I get the total at the last iteration of the while loop but I never get it after while exits.
#!/bin/bash
ps -ly |...
1
vote
2answers
15 views
Trigger a non-zero exit code when I break out of a loop
I'd like to run a series of tasks but stop should any of them fail, hence I've written (something like):
for task in [TASKS]; do
process "$task" || break
commit "$task"
done
This works fine, but ...