Search type Search syntax
Tags [tag]
Exact "words here"
Author user:1234
user:me (yours)
Score score:3 (3+)
score:0 (none)
Answers answers:3 (3+)
answers:0 (none)
isaccepted:yes
hasaccepted:no
inquestion:1234
Views views:250
Sections title:apples
body:"apples oranges"
URL url:"*.example.com"
Favorites infavorites:mine
infavorites:1234
Status closed:yes
duplicate:no
migrated:no
wiki:no
Types is:question
is:answer
Exclude -[tag]
-apples
For more details on advanced search visit our help page
Results tagged with Search options user 7696

Questions about shell scripts, executable files that are interpreted by a shell (bash, zsh, etc.).

1
vote
#!/bin/sh read -p "Enter the width and height of rectangle in meters: " width height sqm=$(echo "$width * $height" | bc -l) sqin=$(echo "$sqm * 1550" | bc -l) echo "Area of the rectangle is: $sqm …
answered Apr 25 '16 by cas
1
vote
You could use 2 cron jobs, one to start the application at 10am and another to stop it at 5pm. 00 10 * * * /path/to/start-script.sh 00 17 * * * /path/to/stop-script.sh If you want them to run only …
answered Sep 19 '13 by cas
1
vote
You say that your .ignorefile has*.txt, *.cpp but from the output shown, it looks like it has \*.txt, \*.cpp. Escaping the * is the source of your problem, it tells find to exclude files with a lite …
answered Nov 29 '15 by cas
0
votes
$ awk -F': ' '/position[0-9]+:|word[0-9]+:/ {w=w" "$2 }; /^[0-9. ]+$/ { w=w" "$0 }; /^[[:blank:]]*$/ || eof {if (w) {gsub(/,/,"",w);print w;w=""}}' muthu.txt [ 0.00000 …
answered May 30 '16 by cas
1
vote
Passing variables like this works but requires the user to understand the internals of your script. It can also cause weird, seemingly inexplicable behavior if the variables happen to be defined in t …
answered Sep 22 '15 by cas
0
votes
There are countless ways that using a regex to parse HTML can go wrong. Even for a seemingly simple task like extraction of URLs from a HTML file. So, don't use a regex. Use something like this ins …
answered May 29 '16 by cas
0
votes
That can be simplified a lot: compare='not ' [[ unix = unix ]] && compare='' echo "they are ${compare}the same" | mail -s "comparison" abc@gmail.com This sets not (with a trailing space) as the def …
answered Dec 27 '17 by cas
6
votes
if [[ $4 == CRITICAL && $2 =~ ^(a|b|c|d|e|f|g)$ ]]; then VARIABLE=1 fi BTW, unquoted variables and positional parameters are safe to use inside [[ ... ]], but not in [ ... ]. In other words, your …
answered Jan 25 '18 by cas
3
votes
printf and ed combined make an excellent tool for scripted editing of files. printf '%s\n' '5r file1' 5d w | ed file2 This uses ed to edit file2. The printf command pipes each of its arguments int …
answered Jun 4 '16 by cas
2
votes
Here's an improved version of your script. It's still pretty crappy because (apart from a bare minimum effort with the initial google search), it makes no attempt to deal with any of the truly awful …
answered May 26 '16 by cas
0
votes
grep M log1.txt | cat -n | sed 's/^[[:space:]]*\([0-9]\+\)[[:space:]]*/\1\)/' >> filesave.txt The sed script is optional if you're happy with the output of cat -n grep M log1.txt | cat -n …
answered Nov 5 '15 by cas
0
votes
#!/bin/bash # Read ip.txt and names.txt into arrays 'ips' and 'names'. This assumes that # the files have the same number of lines, and that both files are in the # correct order (i.e. line N of ip.t …
answered Mar 12 '18 by cas
0
votes
As noted in my comment, unless there's something you haven't told us, there doesn't seem to be any need to use file descriptors other than stdin and stdout here, nor is there any reason not to just pa …
answered Jan 21 '18 by cas
0
votes
You can also do this by iterating over the indices of the array (${!hostlist[@]}, note the !) rather than the values (${hostlist[@]}), and then using unset to delete unwanted array indices. e.g., bas …
answered Mar 12 '18 by cas
1
vote
Here's a shell script fragment that does the job: # try various methods, in order of preference, to detect distro # store result in variable '$distro' if type lsb_release >/dev/null 2>&1 ; then di …
answered Apr 19 '16 by cas

15 30 50 per page