Stack Exchange Network

Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange
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 2343

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.

5
votes
sed -n ':a /^SERVER/{g;p;ba}; h' file | uniq -c | sed -r 's/^ +([0-9]) (.*)/\2\n\1/' Output: Bala Bela;XXXXXX12345;XXXXXX12345678;A 4 Ize Jova;XXXXXX12345;XXXXXX12345;A 3 If a prefixed cou …
answered Sep 14 '12 by Peter.O
5
votes
2answers
? #!/bin/bash # Make a couple of files whose names contain a space. junkd=$HOME/junkd mkdir $junkd # || exit 1 cd $junkd touch f\ {1..2} # echo -n * |xxd # This shows a space between the two names …
asked Mar 11 '11 by Peter.O
4
votes
printf '%s\n' {♠,♣,♢,♡}$'\t'{{2..10},J,K,Q,A} | shuf -n5 | gawk 'BEGIN{ split(",Twos,Threes,Fours,Fives,Sixes,Sevens,Eights,Nines,Tens",vt,","); vt["J"]="Jacks"; vt["Q"]="Queens"; vt["K"]="Kings"; v …
answered Jun 24 '15 by Peter.O
0
votes
[[ -n $(df -h / | awk 'int($5)>6{print $5}') ]] && echo "Warning file system greater than 6%"
answered Jul 27 '15 by Peter.O
4
votes
Sort on keys 1 to 32 (-k1,32), with vertical bar as delimiter -t'|'. -u means: output only the first line of an equal run (of combined keys). See man sort for details of sort's options. sort -t'|' …
answered May 8 '15 by Peter.O
0
votes
On my Ubuntu/Bash system: TM1=A; TM2=B unset TM<ESC><*> => unset TM1 TM2 (expands in the command line) …
answered Dec 31 '11 by Peter.O
2
votes
UPDATE: Here is a bash way to do a single Unicode value ...(by "bash" I mean: not using any another scripting language) .. thanks to Gilles for a suggeston in this askubuntu Q/A . According to this …
answered Apr 29 '11 by Peter.O
0
votes
Here is a way to load the array without using eval. It doesn't use the ( data ) construct - instead it uses an input string with your choice of delimiter - the example uses | i=aaa IFS='|' read -a …
answered Apr 29 '15 by Peter.O
31
votes
3answers
The following examples show that a newline is added to a here-string. Why is this done? xxd -p <<<'a' # output: 610a xxd -p <<<'a ' # output: 610a0a
asked Sep 5 '11 by Peter.O
1
vote
I don't quite know why you don't just use $1 $2, etc.. but.. This may suit your needs. $ script "ed it" "cat/dog" 33.2 \D echo "-------- Either use 'indirect reference'" for ((i=1;i<= …
answered Apr 15 '11 by Peter.O
3
votes
tolower() to allow for a case insensitive comparison, which produces the alphabetical collation mentioned in the question... #!/bin/bash dir="$1"; ref="$2" find "$dir" -maxdepth 1 -type f -printf …
answered Jul 25 '12 by Peter.O
1
vote
awk -v argsec=$((5*60*60)) ' BEGIN{ nowsec=systime() } { logsec=mktime(gensub(/[-:]/," ","g",$1" "$2)); if(nowsec-logsec<=argsec) print; }' logfile Your could put the co …
answered May 25 '15 by Peter.O
4
votes
To remove the \, use bash parameter substitution. // means replace all ... (a single / would mean replace only the first) //\\ means replace all \ (backslash) chars /} means replace with nothing …
answered Mar 14 '12 by Peter.O
3
votes
encountered in the script.. The command's is run and its exit code is tested by if.. Your grep output presents if 3 to bash. if command ;then do-something; fi is okay because if tests the exit code of …
answered Apr 28 '11 by Peter.O
5
votes
Your getsubstr $var0 is passing 5 args to the function. Also, $* and $@ tests each individual $1 $2 etc.. arg against the # patttern. Regarding RegEx in bash: I've added some examples at the end … separately/individually. The following script may help with $@ and $* (by example)... #!/bin/bash # getsubstr() { echo -n " ${#@} args"; [[ "$1$2$3$4$5$6" == *\ * ]] && echo " (with …
answered Apr 7 '11 by Peter.O

15 30 50 per page