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.

learn more… | top users | synonyms

0
votes
1answer
254 views

How do I add integer and floating numbers together to keep tally?

I'm just trying to do some simple math that is not turning out that simple. this is what I have tried so far and I have yet to find anything on the google net that combines integer and floating ...
7
votes
3answers
327 views

Get 100 palindrome numbers

I'm new at scripting and I have this assignment, which is to find 100 palindrome numbers with the following algorithm: Get a two-digit random number (greater than 10) Reverse the number Sum the ...
2
votes
1answer
683 views

Opening multiple tabs in gnome-terminal, having them automatically password-lessly ssh to servers and do so using alias from my bashrc file

I regularly have to ssh into four or so servers we run, at the same time. I have aliased these like. SERVER1=root@server1 alias sshserver1='ssh -t ${SERVER1} "bash -rcfile .my_bashrc"' # Above line ...
1
vote
2answers
202 views

Deleting lines with different patterns in a file

I need to delete lines with different patterns, For example sed '/Paris/d' file.txt | cat -s sed '/London/d' file.txt | cat -s sed '/Rome/d' file.txt | cat -s sed '/Pais/d' file.txt | cat -s ...
3
votes
1answer
137 views

su - -c 'll' other_user results in error, how can I run this other user's alias?

In current bash session, I just want to change to another user for some bash command. The command is aliased to some script defined in another user's .bashrc or .profile. Am I able to make it ...
3
votes
2answers
2k views

Bash: cannot break out of piped “while read” loop; process substitution works

I intend to pipe the output of a program into a while read VAR loop and break when a pattern is found, but it doesn't. Proof of concept: inotifywait -qm -e create . | while read line; do echo $line; ...
3
votes
1answer
426 views

How to format grep results?

Wow, I could not think of a good way to title this question. Basically I have a file called "attendance" with data like this: 11/06/2014 101.11.001.01 FirstName LastName 11/06/2014 101.11.001.01 ...
1
vote
3answers
60 views

How do I analyze report type of data in Bash?

What is the best way to read the following data in Bash? For example if the data is like a ls -l then I could read line by line and I have all the detail of a file within a line. In this case I have ...
1
vote
2answers
1k views

cat STDIN won't work twice in script

I have a script that outputs various information and the text fields of an html form (method POST). When I attempt to cat <&0, it displays properly. However a few lines down, I try to cat ...
5
votes
4answers
2k views

When I run `./command.sh &` the background task is suspended. How can I keep it running?

This is what I'm running: alexandma@ALEXANDMA-1-MBP ./command.sh & [2] 30374 alexandma@ALEXANDMA-1-MBP [2] + suspended (tty output) ./command.sh I don't want it suspended to start, I want it ...
4
votes
1answer
1k views

Fedora 20: Users cannot enter their home directory

Running Fedora 20 on a file server and ran into this strange issue, not sure what I'm doing wrong. The account I made while installing the OS works fine, but every other account I made has this ...
1
vote
1answer
53 views

Bash Script - Controls on two directories [closed]

I would like to write a bash script that implements a command which takes two parameters. The two parameters must be pathname (absolute or relative) of two directories. The two directories are not to ...
4
votes
2answers
633 views

Script working on Mac but not Ubuntu

The script executes on a Mac machine and creates the output file, although on an Ubuntu machine it generates error message. Bash shell is used on both instances.: 1 - /var 2 - /etc : 1 : bad ...
26
votes
2answers
24k views

How to grep the output of cURL?

I need to retrieve the expiry date of an SSL cert. The curl application does provide this information: $ curl -v https://google.com/ * Hostname was NOT found in DNS cache * Trying ...
5
votes
4answers
7k views

Constantly check if file is modified bash

I have a file called file1 I want in a script, whenever there is a change in it, do something, a beep sound actually. How do I do that ¿? Thank you in advance
1
vote
4answers
118 views

How to use regex in sed?

I need to revoke the sudo access to the user using sed in scripts. I want to comment the user only if the line contains /bin/su - root Let us consider the file as below, in which I have to comment ...
0
votes
0answers
137 views

Why does sudo su -l user -c bash fail to load user's environment?

I would like to be able to spawn a fully working shell environment from upstart script. Why does sudo su -l user -c bash fail to load user's environment properly? $ sudo su -l -m adam -c "bash" ...
0
votes
1answer
335 views

Shell script equivelent to PHP $_POST

For example and learning purposes, I have a webpage that uses POST method to submit a text field. I have a server running script (bash) that I want to display what the "Query_string" is. I'm not ...
4
votes
2answers
566 views

Can multiple mv commands be run in the same directory (race condition)?

I'm moving a large number of files (400K+) from one directory to another and I have the following script to do so (too many files for the mv command to work directly): for file in *; do mv $file ...
2
votes
2answers
1k views

How to use pgrep inside bash script correctly?

I'm running a GUI program called zeal(compiled from src) and add a script(zeal.sh) for the executable: #!/bin/bash if pgrep zeal &>/dev/null; then printf "already on\n" else ...
1
vote
1answer
268 views

How to restart my server automatically using crontab if they went down?

I have a jar file which I am running like this in my Ubuntu 10.10 and then it starts my exhibitor server in the background - nohup java \ -jar ...
3
votes
3answers
55 views

How to see manpage of previous command?

For example if I did a curl -F 'clbin=@some-image.jpg' https://clbin.com. How do I man curl easily?
2
votes
1answer
149 views

How do I retain custom PS1 in super user mode?

The problem is this: I set a custom PS1 in my .bashrc, but it changes to the default one when I enter super-user mode. What I expected: ╓[coffee]─[Linux-Tower]─[2014-11-05, 23:41]─[~] ╙[$]-[sudo ...
1
vote
2answers
125 views

Map Return with no other input to an alias

I would like to use Return with no other input to run an aliased command in the shell. Is this possible in Bash or Zsh? In other words, when I enter an empty command line, I want to run one specific ...
4
votes
2answers
7k views

Using a for loop to loop over multiple arrays in bash

Bash doesn't natively support two-dimensional arrays, but I would like to simulate one. As a minimal working example, suppose that I have two arrays, a0 and a1: a0=(1 2 3 4) a1=(5 6 7 8) I want to ...
1
vote
1answer
190 views

Why doesn't `dialog` display the menu (but accepts acceptance) when started through a command substitution expression?

I want to, from a bash shell script, present the user with a menu of choices to pick from. The selection should then be stored in an environment variable for further use later. If I run from the ...
2
votes
3answers
221 views

Running a timed background job in bash

I would like to execute a command in bash every 30 seconds and have it run as a background job. Form this post, I gather that using the watch command is useful. However every time I attempt to ...
1
vote
0answers
248 views

Powerline bash prompt not colorized in tmux

The bash/zsh commandline prompt is not displaying colors in tmux, even though I managed to get the powerline itself working (with colors). The prompt works fine in pure bash/zsh. I am getting the ...
0
votes
1answer
436 views

Shell string escape for command arguments [duplicate]

I'm trying to create "/tmp/pwet/foo bar" with this: DIR="/tmp/pwet/foo bar" ARGS="-p ${DIR}" mkdir $ARGS For integration reasons, I have to keep the ARGS building in 2 steps: ARG = some_options + ...
0
votes
1answer
2k views

mailx: nss-config-dir=/etc/pki/nssdb/: No such file or directory

I am trying to send email using mailx using remote SMTP server (in my case it is office365 SMTP Server). Here is the command: # echo "THis is the Body of the email" | mailx -v -s "This is email ...
4
votes
0answers
203 views

Assign both menu-complete and dynamic-complete-history to TAB

Is there a way for me to assign both menu-complete and dynamic-complete-history to Tab (or one to Tab and the other to Tab-Tab) in .inputrc? I'm thinking there might be a way to setup a function and ...
6
votes
5answers
4k views

How can I programatically tell if a filename matches a shell glob pattern?

I would like to tell if a string $string would be matched by a glob pattern $pattern. $string may or may not be the name of an existing file. How can I do this? Assume the following formats for my ...
0
votes
1answer
95 views

Usage of set -e in Bash

In this script #!/bin/sh set -e exec svlogd ./main Do you know what set -e does? I searched man and Google without luck
1
vote
0answers
195 views

OpenWRT missing OD (octal dump)

I have a bash function using od command. Now I'm trying to run in on OpenWRT and see that in has not od. Also can't find it using install from opkg, because I can't find it. Is there a possibility to ...
4
votes
2answers
574 views

echoing basename under xargs?

I have the following command : ls /some/path/*dat | xargs -n 1 -I @ sh -c "echo `basename @`" with the directory /some/path/ containing : /some/path/a /some/path/b /some/path/c /some/path/d I ...
1
vote
1answer
363 views

How to get the equivalent of tcsh's enhanced completion in bash?

In the tcsh manpage, the effects of set complete = enhance are defined as follows: [...] completion 1) ignores case and 2) considers periods, hyphens and underscores ('.', '-' and '_') to be word ...
1
vote
0answers
2k views

CentOS - upstart script is created, but its never running at all

I have this following setup but its not working in my CentOS 6x (3.10.23-xxxx-std-ipv6-64 #1 SMP Tue Mar 18 14:48:24 CET 2014 x86_64 x86_64 x86_64 GNU/Linux) Step 1: vi /etc/init/a.conf description ...
1
vote
3answers
329 views

Renaming directory bash script - target … No such file or directory

New to bash scripting, and just need a little help. I've been testing this on a simple directory structure. I'm trying to change any directory and/or sub directory with the name "Season" to "Sn". I ...
0
votes
1answer
287 views

Is my linux mint box vulnerable to Shell-Shock attacks? How might I remedy that? [closed]

Is it safe to use Linux Mint now, with ShellShock existing? If not, what can I do to use Mint safely?
-1
votes
3answers
65 views

Look for numbers that is supposed to exist, but doesn't

I have a long list of numbers. Is there any way I could display the numbers that doesn't exist? In this case it would be 2 and 4 1 3 5 6 The list is in a text file. To clarify, I just have one ...
1
vote
1answer
1k views

How to check the time at which the command was executed?

When history command is executed, it shows a list of recently executed commands. Is there any provision with which we can see the time at which those particular commands were executed?
3
votes
1answer
1k views

splitting a CSV and keeping the header without intermediate files [closed]

I am trying to split a dozen 100MB+ csv files into managable smaller files for a curl post. I have managed to do it but with a lot of temporary files and IO. It's taking an eternity. I am hoping ...
1
vote
0answers
200 views

passing variable through cat EOF command with for loop

How do I get the script run with the sbatch command to run with the 23 individual run_prep_chem_$dd.sh (i.e. run_prep_chem_08.sh...run_prep_chem_30.sh)? I am thinking since its in this for loop that ...
2
votes
3answers
163 views

Error while assigning current directory to a variable

#!/usr/bin/env bash if [ "$outDir" == "" ] then echo "$PWD" ,"We are here ", $outDir ," with " "$outDir" = "$PWD" echo "Yes" fi Output on terminal: ...
1
vote
2answers
320 views

bison says invalid option --

I'm using flex and bison in Mac OS Maverick. I can send the bison and flex command in bash without any problem. But when I tried to issue the command using a shell script. I got this error. ...
4
votes
5answers
1k views

how to use regex in alias?

I want to create the alias for the command "ssh user@10.32.44.225" as 10.32.44.225 alias [0-9][0-9][0-9].[0-9][0-9][0-9].[0-9][0-9][0-9].[0-9][0-9][0-9]="ssh user@$0" I have created it, but it is ...
1
vote
1answer
70 views

Cannot get 'match-hidden-files' to work

I have been trying to get 'match-hidden-files' to work on bash 4.3.11, but I can't. I wanted to make sure it's not something I'm doing wrong. $ grep match-hidden-files .inputrc set ...
0
votes
3answers
105 views

How do I search a file for a string then use it as a variable?

I have an XML file that looks like this: <id>456</id> <root> <value>1</value> <intNum>2</intNum> </root> <root> <eulav>1</eulav> ...
1
vote
3answers
425 views

WMCTRL not working after starting xfce4-terminal

If I type these two commands in a terminal: xfce4-terminal --hide-menubar --hide-borders --hide-toolbars --title=dt wmctrl -r dt -e 0,10,10,720,720 I get the desired result (position and resize of ...
3
votes
3answers
83 views

How can I base the file name off of an already existing variable?

I'm using this to delete lines that don't match a pattern: $ egrep "pattern1|pattern2|pattern3|pattern4|pattern5" But now I need to do it automatically, so I'm setting a variable like this: $ ...