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

1
vote
2answers
28 views

Difference in output from shell script

I am running a simple shell script which has a for loop and kicks off 16 threads in the back ground and waits for each of them to finish before moving on the next commands. Here is the shell: ...
0
votes
2answers
21 views

~./inputrc file not sourcing correctly

I have this ~/.inputrc file that I created for certain key bindings. # mappings for Ctrl-left-arrow and Ctrl-right-arrow for word moving "\e[1;5C":forward-word "\e[1;5D":backward-word ...
1
vote
2answers
32 views

Using sed with herestring (<<<) and read -a

I use sed with <<< and read to assign all words in a string to variables. What I do is: read -a A0 <<< $(sed '2q;d' /proc/stat) Hence, sed reads the second line of the file file ...
1
vote
2answers
65 views

Process substitution with input redirection

I am trying to understand input redirection in combination with process substituation. I am using bash 3 An example with tr is the following $ tr "o" "a" <(echo "Foo") tr: extra operand ...
0
votes
1answer
15 views

How to set & retrieve a cookie via an executable bash script that is on the web

A simple bash script that can set a cookie when executed via web : #!/bin/bash echo "Set-Cookie: eee=1" echo "Content-type: text/html" echo "" echo "test" I replaced the entire codes above with the ...
0
votes
2answers
24 views

Searching out a pattern from Logs

The format of the logs is in this manner: Junk Junk Junk : Junk Junk Junk:IP/Port Junk Junk I want to search using the IP and the output should be only the IP/Port part of each line in that log ...
1
vote
0answers
19 views

PID of process causing error

I have this script: #!/bin/bash # -> dump.$pid ulimit -c unlimited # trap ERR set -o errexit # also trap error in the middle of a pipe (1) # otherwise it will only trap the error on (2) set -o ...
0
votes
1answer
32 views

How to start several jobs in different screen sessions in a Bash-script?

The programm I want use can be started via ./myprogram < input_part1.txt > output_part1.txt How can I start four jobs of myporgram in a BASH-script where each job runs in a separate ...
0
votes
1answer
36 views

Alias for finding a file not working in bash

The following alias for finding a file works in tcsh but not in bash. alias ff "find . -name '*\!{*}*' -ls" When I put the above line in .bashrc and then source it I get : bash-3.2$ source ...
0
votes
2answers
44 views

Finding groups of IP addresses in a file

I have some files with groups of IP addresses. The file looks like this: London: 1.1.1.0-1.1.1.200 172.25.2.0-172.25.2.100 Germany: 2.2.2.0-2.2.2.100 192.168.1.0-192.168.1.200 172.25.2.0-172.25.2.200 ...
7
votes
1answer
160 views

How to start XTerm with prompt at the bottom?

When starting XTerm the prompt starts at the first line of the terminal. When running commands the prompt moves down until it reaches the bottom, and from then on it stays there (not even Shift-Page ...
0
votes
0answers
21 views

terminal valid path doesn't exist [on hold]

I am having an odd issue where a path I generate from an HTTP POST does not register as valid, even though it clearly is. For example: This generated path ...
1
vote
1answer
24 views

Global variable for every script

I want to declare a variable in such way that every script can access and alter its value. I have written a script that set the value of a variable called flag on exit and I am using a crontab entry ...
0
votes
1answer
20 views

apt-get update: How to check for GPG errors when using scripts?

When running. sudo apt-get update For example something like this could happen. W: GPG error: http://deb.torproject.org wheezy Release: The following signatures were invalid: KEYEXPIRED 1409325681 ...
2
votes
1answer
98 views

How to print a bash variable that has an array as value

I wrote a script for my dwm statusbar. One part of it is finding the current cpu usage for every single core on my system. I figured out a way myself but I would need some help fixing a bug in this. ...
0
votes
1answer
29 views

OS X - Terminal - initial bash shell broken, with a: syntax error near unexpected token `('" [on hold]

Something weird has just started to happen, when I open a new terminal window the initial shell is broken, recieve a "syntax error near unexpected token `('" error when I try to use any conditional ...
1
vote
0answers
48 views

Load a background image or set the background color if Konsole/Shell is running SSH

I want to set my laptop to load an image in the shell's background or set the background color to red if I'm connected via SSH. How can this be done? With a bash function in .bashrc? I have: Set the ...
2
votes
3answers
100 views

How to get cpu usage for every core with a bash script

I'm writing a bash script to print system stats to my dwm status bar using xsetroot. Everything works as expected. What I'm currently missing is an easy way that just uses standard *nix tools to give ...
2
votes
3answers
111 views

Should I embed a command in a conditional or test its return code?

It's a simple question of best pratices: Which should I use? Option 1 ping -c1 "$host" if [[ $? -eq 0 ]] ; then command else command fi Option 2 if ping -c1 "$host" ; then command ...
-1
votes
0answers
17 views

FreeBSD switch to user with nologin

I am running FreeBSD jails. i have a user i need to login as to run some commands. The user shell account is nologin. Without switching the users shell. or running su commands for each command i need ...
0
votes
0answers
41 views

Terminal freezes after using tar or gz

On Linux within bash the Pseudo Terminal window (terminator) as well as the Terminal itself "freezes" when trying to use autocomplete (TAB) as well as after getting an error message using gzip and ...
1
vote
1answer
29 views

How to ensure a bash script is executable via web without being in /cgi-bin directory?

My document root is /0/ i do not have any cgi-bin directories. this is my virtual host with apache: Listen *:80 DirectoryIndex 1 <VirtualHost *:80> DocumentRoot /0 ServerName domain.tld ...
1
vote
2answers
44 views

Which part of this bash PS1 config determine the color?

I got my git branch color set by this tutorial:http://www.bramschoenmakers.nl/en/node/624 But recenlty I've reverted my terminal background color, and the yellow branch name is nearly invisible under ...
0
votes
2answers
53 views

Can I use seq to go from 001 to 999? [duplicate]

Can I use seq to go from 001 to 999?
3
votes
1answer
40 views

Run Script at fail login attempt?

Lately, I've been trying to create a Bash script to capture a webcam photo when a fail attempt to login is registered. First of all, I found 2 guides related to this (links at the end), they explained ...
2
votes
1answer
78 views

How does VARIABLE=() { function definition } work in bash

I have seen something like this in my bash ENV: module=() { eval `/usr/bin/modulecmd bash $*` } How does this construct work? What is it called? I'm not asking about modulecmd, I am asking about ...
0
votes
1answer
22 views

What's with `-` in filename affecting sorting order depending on platform? [duplicate]

I just checked if contents of directory on my cygwin/Win7 development system, and test embedded platform running Linux+Busybox are the same. Simple, cat * | md5sum on both (RXVT/Bash on Cygwin, serial ...
1
vote
3answers
47 views

Bash script in ( set -x ) mode does not display what “cat” command does. ( contents of it )

in this bash script.. it simply shows.. +cat as it runs. #!/bin/bash set -x cat > /test << "EOF" a b c d EOF but i rather show everything that it does . including the a b c d ...
1
vote
1answer
32 views

Can I start a background process with a specific working directory?

Say I have this structure /masterscript /a/script1 /a/b/script2 In masterscript I spawn the other scripts as background processes: "/a/script1" & "/a/b/script2" & The problem is that ...
4
votes
3answers
379 views

Why can't I `tail -f /proc/$pid/fd/1`?

I wrote a simple script which echo-es its PID: #/bin/bash while true; do echo $$; sleep 0.5; done I'm running said script (it says 3844 over and over) in one terminal and trying to tail ...
0
votes
1answer
41 views

Running shell script on cluster in parralel

I thought dsh(Distributed Shel) will be a good option but when i ran my shell script across my nodes, I didnt get expected output, dsh -aM -c bash /home/cloudera/bash_script.sh server2@x.x.x.110: ...
2
votes
3answers
88 views

bashrc in custom folder [duplicate]

I want to cleanup my home folder and have managed to move out most of the configuration files to the .config folder. But, one file I'm not able to figure out is the .bashrc file. How can I specify ...
0
votes
0answers
23 views

bash script to verify rhel patching

we have several redhat servers which we patch from redhat satellite. To avoid confusion, I'll use the term "host" to denote the server which is being patched. We have a script, say, patch.sh, which ...
2
votes
1answer
36 views

Bash: How to get different color for the command line and its output? [duplicate]

Basically, I am trying to edit my .bashrc such that when I type ls or whatever I type on the console, it will be displayed in Green color. At the same time, all the results / output displayed by ls or ...
0
votes
1answer
36 views

What does bash -l do and why can't it find ssh?

I have GitBash installed in a windows 7 box and I'm trying to figure out why running: bash -l ssh results in Welcome to Git (version 1.9.0-preview20140217) Run 'git help git' to display the help ...
1
vote
0answers
51 views

How to start a process chain from the shell

Is it possible and if so how do I: Start a /bin/bash process that is not bound to a terminal from a terminal? Hence, a shell process that shows up in the process tree as init -- bash. (Shells ...
6
votes
2answers
253 views

Why does source give an error “cannot execute binary file”

I have small file that does initialize a tmux session and then creates some windows. After some debugging and tweaking things worked fine until I renamed the text file (with the tmux commands) from ...
6
votes
2answers
148 views

Bash string concatenation used to build parameter list

Given this piece of bash: PARMS='-rvu' PARMS+=" --delete --exclude='.git'" echo $PARMS rsync ${PARMS} . ${TARGET} The echo shows the PARMS string as expected, no error is displayed, but rsync ...
-5
votes
0answers
28 views

Print lines if lines across four files does not have either Partially Successful or Successful Full [closed]

Hi I have 4 files like below each file has one week information, I would like to print lines if lines across four files does not have either Partially Successful or Successful Full corresponding to ...
1
vote
2answers
82 views

I want to suppress “no access to tty” error message?

I have a bash script where I use ssh to connect to another server and run some commands there. I found some sites that the error (Warning: no access to tty (Bad file descriptor). Thus no job control ...
3
votes
1answer
47 views

Suppressing “sudo: sorry, a password is required to run sudo” [closed]

I am trying to test if a user has the required sudo rights to run a command as another user without providing a password. What I have is this sudo -u other-user -n true if [ $? -ne 0 ]; then ...
0
votes
1answer
35 views

Bash STDERR still appearing after redirection [closed]

I am trying to parse the output of yum check-update in Bash 4 (Red Hat) and want to skip the first line that states: 'This system is not registered to Red Hat Subscription Management. You can use ...
3
votes
1answer
27 views

Bash ignoring my PATH and it's cache

I have installed pip in my ~/.local/bin/ directory. Here are the outputs of which, type and $PATH $ type pip pip is hashed (/home/bcc/pedros/.local/bin/pip) $ which pip /usr/bin/pip $ echo $PATH ...
1
vote
2answers
45 views

How to combine arithmetic expansion and brace expansion? [duplicate]

Can peoples combine arithmetic expansion and brace expansion? $ for i in {$((1 + 1))..5}; do echo $i; done; {2..5} $ echo "bash laughs at me"
4
votes
1answer
100 views

`seq` and bash brace expansion failing

IINM my system is failing when bashing for i in {0..10000000}; # Seven zeroes. do false; done # `bash` exited and its `tmux` pane/window was closed. or for i in $(seq 0 10000000); # ...
3
votes
2answers
85 views

Bash -c with positional parameters

Usually, $0 in a script is set to the name of the script, or to whatever it was invoked as (including the path). However, if I use bash with the -c option, $0 is set to the first of the arguments ...
2
votes
2answers
47 views

How to make bash script ask you if you want to execute the next segment(part)?

Soon as I execute the bash script. Given that I have set -x I will visually observe what is happening. But at certain parts, I want it to stop and ask me if I still want to continue executing the ...
4
votes
1answer
56 views

Bash script for scp interpreting tilde (~) too soon

So, I just started a new C++ class that requires me to program in a Linux environment. I don't have Linux installed on my machine, but I do have OS X and I can ssh into a linux machine in the lab at ...
0
votes
2answers
23 views

is there a way to escape a process in bash with out quitting it? [duplicate]

For example, I type sudo apt-get update and then a long list of stuff will come up for minutes.. if I want to escape from seeing this tiresome updating and take control of bash command line ...
1
vote
3answers
100 views

How to do command-line completion with files and folders

As a new Linux user, one of the things that's kept me away from the Command Line (CL) is that, for tasks involving files and folders (i.e. everything!), the amount of typing involved makes using the ...