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

How to add a folder to a remote hosts PATH using a shell script?

I'd like to automate the process of syncing a local ~/bin folder to a remote host, and adding that folder to my remote shell's path. I've got the syncing part done, but am not sure how to automate ...
0
votes
1answer
37 views

How to add new column, where the value is based on existing columns with awk

I have a file of multiple columns. I would like to make an additional column based on the values of 2 columns from this file. Example input: A B C D E F 1 2 T TACA A 3 2 3 4 I R 8 2 9 3 A C 9 3 ...
3
votes
1answer
153 views

Exit bash when find gets to a folder with permission denied

I'm trying to write my second Bash script. Where i go through folders recursively and make a list of and count files and folders. In a way it works but if "find" gets to a directory where it has ...
1
vote
1answer
19 views

adb pull not accepting a variable as source, gives *' does not exist..* error

I'm trying to use $EXTERNAL_STORAGE in the adb pull command. I noticed that the variable has its scope defined in Android only and so it would not work successfully in adb pull ...
3
votes
0answers
70 views

How to best track adventures of a novice administrator

I have this user that has limited sudo privileges, yet he manages to screw up from time to time. I would like to keep an eye on his adventures, so that I can reverse any damage with less digging. ...
0
votes
3answers
55 views

How to execute source command from sh file

I have file called install.sh and within this file I write something to $HOME/.bashrc file and after that I must call source command. In terminal I can type source $HOME/.bashrc but I can't do this in ...
1
vote
1answer
8 views

Outputting PID of Rails server(s) with ps aux | grep - breaks when put into an alias?

I'm trying to create an alias for an unwieldy command I'm using to output the PID and some other information about two rails servers I have running. When I simply run the command in terminal (over ...
1
vote
1answer
39 views

Identifying duplicate fields and print both with awk

I have a file with multiple columns and want to identify those where specific column values (cols 3-6) have been duplicated. The following code finds the duplicates but I want to display both ...
0
votes
2answers
37 views

How to store whole a paragraph as one element of array in bash script

I am using the following code to read data from a file abcd.txt and try to store in an array parameters, I am able to store 619617 in parameter[0] and update in parameters[1] but in parameters[2] I am ...
1
vote
0answers
40 views

Debian Jessie, copy file on NFS share (autofs) at shutdown

I'm on Jessie 8.1 so I use systemd to launch a service at shutdown. My service uses a script to copy a file on a NFS share (mounted by autofs). It doesn't work, I know the script can copy a file on ...
0
votes
2answers
30 views

Bash script error [closed]

I created this bash script based on answers I found here: If [[ $(autorep -J jobname | cut -c108-110 | sed -n '/ST/!'p | sed '/^$/d' | sed -n '/_/!'p) == *ST* ]]; then echo "Status is Started" fi ...
1
vote
2answers
67 views

Cron only occasionally sends e-mail on output and errors

On Debian 8.1, I'm using a Bash feature to detect whether the stackoverflow.com website is reachable: (echo >/dev/tcp/stackoverflow.com/80) &>/dev/null || echo "stackoverflow unreachable" This is ...
1
vote
1answer
29 views

How to suppress exit code of finished background jobs

Is there a way to hide the exit code of the background jobs that have finished? For example, if I run: sleep 5& After the 5s, if I hit return the terminal gives me: [1]+ Done ...
0
votes
2answers
56 views

sed in while read loop doesn't complete commands

I have a test file called testPage with the following text: || '''Title1''' || '''Title2''' || '''Title3''' || || Cell11 || Cell12 || Cell13 || || Cell21 || Cell22 || || Cell31 || Cell32 || || Cell41 ...
0
votes
1answer
27 views

Display Spinner while waiting for some process to finish

How can I show spinner till command line finish it is job? In other words, If I am running a script and I want to show spinner while this script is running and the spinner disappears when the script ...
0
votes
1answer
29 views

DNS Query Script

I am trying to get all the A records for some domains. The best way I have found is to use https://www.whatsmydns.net and the nexcess tool. The issue is that it is very slow to copy paste them and ...
0
votes
0answers
7 views

Zenity, how to manage cryptsetup prompt?

With Zenity, I display a progressBar and install/config many stuff on a Linux Mint (Debian) computer. I had to avoid any prompt. But one step prompts Enter a passphrase:, this is cryptsetup ...
0
votes
0answers
14 views

Zenity. How to run as an application?

I built a script (bash), then I overlaid it with Zenity (to have a progressbar in a GUI for non linuxian users). How can I deliver it as an app, not a .sh ? And never show a square of terminal ?
0
votes
1answer
7 views

Find line within file matching pattern and make a substitution

I'm trying to simplify my life here but I'm stuck. I have a file containing multiple lines. Each line has a user and a number. I'd like to know a bash one-liner to search for a user and change the ...
1
vote
1answer
87 views

'while read line do' cause: “syntax error near unexpected token `done'” in Linux bash script

I have a shell script which is running fine on Solaris platform but not working on Linux platform. The Failing code snippet is as following: [...] while read line do insert_into_table="insert into ...
0
votes
2answers
24 views

Bash script to edit lots of html documents

I have a directory with many HTML documents. Most of them contain the codeblock .org-link { /* org-link */ color: #b58900; font-weight: bold; text-decoration: ...
0
votes
2answers
50 views

Bash script that removes part of a filename in every file under a directory

I have several files under a directory whose names are of the form *.foo.bar. I would like to write a bash script to rename each of these files by removing the .foo part. For example, suppose that ...
0
votes
1answer
20 views

Running repetitive task through Bash script

I'm running a few repetitive tasks and I think will be good to create a small bash script to perform all them in just one command: run the bash script. This are the tasks I need to run: # stop HTTPD, ...
1
vote
1answer
47 views

Script SSH and run command

I must connect to server every day by ssh, and I made a script to display logs. This is my code: #!/bin/bash A=`date +%Y` M=`date +%m` D=`date +%d` gnome-terminal --geometry=82x11 \ --tab --title ...
0
votes
2answers
32 views

How to use if with grep -x

This is my code: if grep -x $idle | grep -x $dead | grep -x $busy ./Event.log then echo " Events are running Successfully" >> ./Event.log else echo "One or more Events are down. Check ...
0
votes
1answer
21 views

Command does not execute properly on remote server

I've been trying to update my backup script such that it saves data on a remote server instead of on a local disk. I have succeeded in converting the entire script but the last part in which I remove ...
1
vote
3answers
115 views

in bash script; a process stdout as filename argument fails when you open it more than one time

Consider this bash script code: #!/bin/bash function bug_part() { cat $1 > sample.first cat $1 > sample.second #second time you open file $1, it contains no data } bug_part <(echo ...
2
votes
1answer
30 views

How to script `make menuconfig`?

I want to automate a linux build but eventually get to a point where I need to run what seems to be a very manual step: make menuconfig. This seems to synchronize configs between the OS and kernel ...
0
votes
1answer
36 views

Keys in the keyboard are not functioning in an interactive script!

I am using this code in bash to make my script interactive. I mean by interactive is to let the script ask me questions like what is the path to my data: #!/bin/bash -ef read userInput if [[ -n ...
1
vote
4answers
81 views

Last Working Day of the Month

#!/bin/bash #!/usr/local/bin #!/usr/sbin #!/usr/bin # Script to Check last working Day of the Month echo " Enter Month and Year :" read mon year cal $mon $year| egrep "28|29|30|31"|awk 'BEGIN { ...
0
votes
1answer
19 views

not getting variable's values inside the isql command

Below I am trying to automate the Sybase reporting job but unable to get the variable value as sp_helpdb proc's parameter. Kindly assist me to get out of this. #!/bin/sh . ./SYBASE.sh dblist=`isql ...
0
votes
0answers
29 views

What are the advantage of using tcsh? [duplicate]

I'm a newbie to Linux. I have found tcsh has some advantages over bash. What are the significant advantages using tcsh over bash? For C Programmers is there any specific advantages that bash cannot ...
-2
votes
0answers
25 views

Script to test speed of a list of DNS addresses

I'm writing a unix script, I need a way to find the fastest DNS from a list of DNS addresses. I found how to check the response time of one DNS address: time dig a www.google.com @79.120.211.147 but ...
2
votes
0answers
21 views

When would you use $* instead of $@ in Bourne shells? [duplicate]

In Bourne shell and its offshoots like Bash, I believe the only difference between $* and $@ is that $@ expands in double quotes so that each argument ends up as a single word even if it contained ...
1
vote
0answers
29 views

What exactly files whose names' prefix is “AT.postflight.” are needed for?

I am not sure if this question should be asked here, since I am on an OS X, but since I am using bash, and I am asking about the meaning and the purposes of some files. I am trying to understand why ...
-4
votes
2answers
45 views

Web Server Log Analyse

I have a web server log file I have to create a command-line pipeline to display the top ten most visited pages. I then have to embed it in a shell script. I'm completely new to Linux coding so how ...
2
votes
2answers
56 views

Find last time yum update was run

Am building a script to find out when a list of servers was last fully updated with yum update. I can find it by a history |grep "yum update"|head -n 1 however, the problem is that a user could have ...
2
votes
1answer
23 views

What affect does precedence have on background task execution?

The two examples I have are: echo hi & And: (echo hi &) The first will give me the process id as a return result (e.g. "[1] 5627"), where adding precedence operators removes this. What ...
3
votes
1answer
128 views

How do I append an item to an array in a pipeline? [duplicate]

This script should simply add a value to an array through a loop and then show all items of an array. #!/bin/bash data_file="$1" down=() counter=0 cat $data_file | while read line; do \ ...
1
vote
2answers
39 views

(Bash) kill process according to the memory used

i make this script to close a process, but i can't compare a output awk (var1) with a integer. the problem is casting in bash? #!/bin/bash var1= free -m |awk 'NR == 2'| awk '{print $3}' var2= ps ...
4
votes
3answers
82 views

How to use call-by-reference on an argument in a bash function

I am trying to pass a "var name" to a function, have the function transform the value the variable with such "var name" contains and then be able to reference the transformed object by its original ...
0
votes
1answer
14 views

Delete files that are not linked from an html file

Given an html file, something like myfile.html, and a folder with some files in it that are part of the web-page and others that are not linked in the html. How can you delete the files that are not ...
3
votes
2answers
33 views

Function with many arguments but only one switch

I am effectively making a recycling bin via some scripts I made. The first script is pretty much an alternative to the rm command (instead of actually deleting a file, it moves it to a deleted ...
6
votes
2answers
74 views

Notification Listener Behaving Strangely when Backgrounded

I've been struggling to get my IRC-Bouncer/Notification Script working. This is meant to be a script which will automatically login to a remote machine, attach to a screen session (or start one if ...
0
votes
1answer
55 views

Bash will not execute system command in Perl script

Need a Bash file to run a perl script. This is the Perl file. #!/usr/bin/perl -w use strict; system "fastacmd -s $Q -d $NewQuery -o ./gifiles/$Q.$NewQuery.txt"; I have left alot out to avoid ...
0
votes
0answers
28 views

Bash Completion hangs all inputs

When I try to bash complete in terminal my computer stops responding to inputs, although the mouse can still be moved. After a few seconds it picks back up and everything continues normally. I'm ...
4
votes
2answers
68 views

How to shutdown a list of servers, making sure the first one is off before shutting down the next?

I have a list of 17 servers in this format: 172.16.6.45 i-052463fs (test-mv1) 172.16.6.46 i-9e2263rf (test-mv2) I'd like a script that can ssh/login to each and every of these servers and ...
-2
votes
1answer
24 views

Shell script curl limit the try time for page not found

I found following code to check web url. if curl --output /dev/null --silent --head --fail "$url"; then echo "URL exists: $url" else echo "URL does not exist: $url" fi Here if the page not ...
2
votes
1answer
90 views

Why root bash output is colored but `sudo ls` output is not?

In bash (Ubuntu) I get colored outputs either as root (after sudo su) or as a normal user. I checked (after reading this post) the files .bashrc for normal user and superuser and the options related ...
2
votes
2answers
51 views

Alias doesn't seem to read from STDIN

I'm looking for an alias to convert hex from hexdump output into "Python's" hex notation: $ echo "5f 74 34 0c c9 7b 9f f8 7a 7c 46 ff ff 5c 31 26" | sed 's/ */\\x/g' | awk '{print "\\x"$0}' ...