The bash-script tag has no wiki summary.
3
votes
2answers
51 views
Running commands after event based outputs
there are commands like
iwevent
or
tcpdump -n src host x.x.x.x
that send to the stdout some lines when something happens. Is there any form of running some command inmmediatly after a ...
0
votes
2answers
43 views
Run level script - Help
I want the following command to be ran, as soon as system boots.
glances -s -P redhat &
How to achieve that?
I tried writing a run level script which didn't work as expected.
1
vote
1answer
50 views
How to assign result of sed to variable
Below is a complete copy of a demo I'm using to to figure out to get the sed command to get rid of the spaces in a persons name, and compress it down to not have spaces.
Once this is done, I want to ...
1
vote
1answer
67 views
What is the use of ; in a single line command?
What does ; mean in single line scripts like this:
while true; do sudo -n true; sleep 60; kill -0 '$$' || exit; done 2>/dev/null &
Does it mean new line, or "next command"?
8
votes
2answers
222 views
Regular expression in bash script
This is my first time bash scripting so I'm probably making an easy mistake.
Basically, I'm trying to write a script that gets the groups of a user, and if they are in a certain group, it will log ...
1
vote
2answers
79 views
Why does this not work when the load average exceeds 1?
I have been testing this script and its behavior has been odd. The script should generate notifications whenever the load average exceeds a specified limit.
Whenever I pass a CPU_LOAD_LMT >=60, no ...
0
votes
1answer
45 views
List of 'if' switches anywhere? [closed]
Is there a list of all the if switches for use in bash scripting? Sometimes I see someone using it and I wonder what the switch they're using actually does.
Example is the -z in this one. I know how ...
3
votes
3answers
86 views
Rename the last 8 characters in filename
I am receiving video files with different names but the final 8 characters of all are numbers (also different every time). This is the pattern of the file name:
custom text 00030402.avi
I have to ...
3
votes
1answer
50 views
How do I fix the argument received from getopt?
I have the following commands in my script:
set -- `getopt -q agvc:l:t:i: "$@"`
...
while [ -n "$1" ]
do
-i) TIME_GAP_BOOT=$2
shift ;;
...
sleep $TIME_GAP_BOOT
When invoking the script ...
1
vote
1answer
38 views
Scrot command - how to save only thumbnail
I'm using scrot to take screenshots from terminal.
However when I want to generate thumbnailed version using parameter -t, I got two files: screenshot.png and screenshot-thumbnail.png.
How can I ...
10
votes
5answers
374 views
Bash script to get ASCII values for alphabet
How do I get the ASCII value of the alphabet?
For example, 97 for a?
0
votes
3answers
55 views
bash script check if variable is is [A-Z]
How do I check if a variable is in [A-Z]
I want something like this:
read var
while [ $var in [A-Z] ]
do
#code here
done
How to achieve this?
2
votes
1answer
54 views
download pdf files from using curl
How to download hundereds of .pdf files from http://www.ncbi.nlm.nih.gov/pmc/articles using a loop, for example for the following document ids:
PMC3386155
PMC3625956
PMC3477654
PMC3531051
...
2
votes
3answers
85 views
Use & (ampersand) in single line bash loop
I have been using this command successfully, which changes a variable in a config file then executes a Python script within a loop:
for((i=114;i<=255;i+=1)); do echo $i > numbers.txt;python ...
0
votes
1answer
74 views
How to force google/youtube searches using the bash? [closed]
I am a bit new to linux (using mint). I am familiar with some of the commands and learned a bit how to write shell/bash scripts.
Anyway, I'd like to know how to force the bash to do a Google or ...