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
0answers
10 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 ...
0
votes
0answers
14 views

terminal valid path doesn't exist

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 ...
0
votes
1answer
15 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
16 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
78 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
26 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
40 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
50 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
2answers
104 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
14 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 ...
1
vote
1answer
22 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
51 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
76 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
41 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
372 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
38 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
84 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
22 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
45 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
250 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
146 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 [on hold]

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
78 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
44 views

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

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
34 views

Bash STDERR still appearing after redirection [on hold]

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
98 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
84 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
46 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
47 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
97 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 ...
1
vote
0answers
21 views

Bash tab completion fails inside of command substitution

I've been using kill $(pidof ) to terminate programs for a while, and since last night, every time I try to use tab completion inside the $() it throws an error, bash: unexpected EOF while looking ...
1
vote
2answers
34 views

profile.d on headless server

Is it a bad idea to put variables needed by a daemon program running at boot on a headless system in /etc/profile.d/? From my understanding profile.d doesn't get executed until someone logs into the ...
3
votes
1answer
69 views

Set Ubuntu System Proxy Settings without Restart from commandline

I am using Ubuntu 14.04 . I want to change the http proxy settings from the command line. This should be equivalent to changing in the GUI(All Settings->Network->Network Proxy) and clicking the button ...
1
vote
2answers
31 views

Restarting a service from a script

I have a init script - /etc/init.d/myservice, which starts some processes, including a CLI process. And from this CLI process, I am adding a command which can be used to restart the service (restart ...
2
votes
1answer
104 views

Sort the 'last' output by month

I know that the command last | tac is enough, but I want to do it using the sort command. I cannot sort it by column, it always sorts the first one only. Using bash on Arch Linux.
2
votes
2answers
73 views

find file, copy but with different name

I have files with random numbers in /home/user/files folder (every 4 days I have new ones). for example: john20 john25 john40 tom12 tom32 simon2 simon8 simon53 I want to take only last modified ...
0
votes
0answers
38 views

Is there any suggestion to my bash script that (un)mounts an ISO file in order to make it better and safer?

I am new to bash script, and I wrote a script to mount / umount an iso file by detecting whether the /media/iso-file-name exists. Is there any suggestion for the script as below in order to make it ...
1
vote
2answers
32 views

Find out which process is in foreground on bash

I have a bash session open for which I have the PID, although I am not in control of the terminal (e.g. could be another user). This bash session has spawned some child processes. Is there any way to ...
2
votes
1answer
21 views

How to get clicked-on filename as argument of shell script triggered by this mouse-click

If, in Ubuntu's Nautilus, I click a midi-file, a window opens to specify an application for processing the file. Another option is a "user generated command" (UGC). (Let me choose Ubuntu, Nautilus, ...
2
votes
3answers
56 views

at job seems to be running using /bin/sh though I have a #!/bin/bash

I am trying to run a job using at, and I have a bash script (I do have #!/bin/bash as the first line), but the job fails because of use of [[ and ]] in the script, I see the following in the mail that ...
2
votes
3answers
138 views

Saving individual output lines into variables

I'm using find -mtime -2 to find files modified in the past 24 hours or less. The output looks like this. /home/user/logs/file-2014-08-22.log /home/user/logs/file-2014-08-23.log I need to save the ...