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
26 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
12 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
4 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
84 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
46 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
31 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
114 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
28 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
0answers
16 views

Character shows up when scrolling through history with arrow keys [closed]

I am thinking my problem is the same (or very similar to) this question but I don't understand the solution if it applies. The selected answer states to use \[...\] to wrap sections with length 0 in ...
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
79 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
18 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
24 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
54 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
127 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
37 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
77 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 ...
4
votes
1answer
45 views
+100

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
51 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
89 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}' ...
2
votes
1answer
40 views

Is there any plugin for zsh or bash that does heuristic filename completion?

Such as if $ ls program_v1.21.rb program_v2.01.rb program_v2.01_final.rb so when I $ echo progv2fin[TAB] it completes to $ echo program_v2.01_final.rb Sure there must be something, but I ...
5
votes
3answers
587 views

For loop formatting

I am having trouble formatting nested for loops for long strings of input: I am currently using the below nested for loops to name output files from a separate program that I have omitted: ...
1
vote
1answer
50 views

Prevent path autocompletion from using CDPATH in bash?

On my Mac, bash (version 3.2.53(1)) autocompletes command-line arguments using files only in the current directory. On a Linux machine at work, bash (version 4.1.2(1)) autocompletes command-line ...
0
votes
1answer
33 views

Running script through bashrc causes nesting of tmux panes

I use the following tmux code in a script file tmux-dev.sh and add it to bash using bash /home/rohit/tmux-dev.sh : tmux new-session -d tmux split-window -h tmux split-window -v tmux -2 attach-session ...
3
votes
2answers
129 views

Subtract floating numbers in shell script

I'm trying to do some calculation in shell script with CPU usage. Which return floating point number. But when I subtract this number I'm getting error. See the following code and error. Code ...
3
votes
1answer
29 views

How do you make an alias or function that retains tab completion?

I made an alias to save some keystrokes with working with systemd: $ alias sctl='systemctl' However, this breaks tab completion for the subcommands. Is it possible to alias a command without ...
3
votes
1answer
10 views

Linux init script what does 0<&- &> achieve

Sorry if this is the wrong medium to ask this question. I looking into writing my own init.d scripts to control several services running on my Linux server. I came across an example online which ...
3
votes
1answer
166 views

Shell script error (: not found [No such file or directory]) [duplicate]

I'm using following script on linux server. And which is giving: : not found [No such file or directory] This is the script: # ------------------------------------------------------------------ # ...
1
vote
1answer
44 views

How to use sed to replace keys in a file using a regex?

I would like to modify a file to replace keys, suppose these keys are in the file as: 42NM 52NM 23NO XNNM I would like to replace anything with NM, with the word "Okay". 1 #!bin/bash/ 2 3 if [ ...
0
votes
1answer
31 views

When I press tab for autocomplete in bash I get: “Cannot parse arguments: unknown option -r” [duplicate]

My tab key's autocomplete function is not working. Instead, it spits out this error message: Cannot parse arguments: unknown option -r
2
votes
2answers
37 views

Using reverse SSH tunneling in one step instead of two steps (with -X)

Suppose we have three hosts: miki - my computer behind a NAT vps0 - my VPS mum - computer of my mother, behind a different NAT. The task is to connect from my computer to my mum and keep X11 ...
0
votes
1answer
58 views

I can't change user's passwd on ubuntu

I want change 120 user's password. so I wrote sudo echo 'user:passwd' | chpasswd but I had a message, chpasswd: (user) pam_chauthtok() failed, error: Authentication token manipulation error chpaswd ...
0
votes
1answer
28 views

echo or sed out of a ks-file to generate a mysql_secure script

i will create a KS File (Kickstart for automated OS installation). i install mariadb with the ks file. But it seems a problem to execute the mysql_secure script. My idea is to generate a script in ...