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 1131

The shell is Unix's command-line interface. You can type commands in a shell interactively, or write scripts to automate tasks. Use this tag for questions applying to /bin/sh and most compatible shells (ash, bash, ksh, zsh, …). For shell scripts with errors, please check them in http://shellcheck.net before posting here.

5
votes
2answers
The default delimiter in awk is white-space to non-whitespace change. The default for cut is the tab character. Can I tell cut to use non-white-space to white space delimters? E.g. a: foo bar c …
asked Aug 29 '10 by maxschlepzig
1
vote
I can't live without set editing-mode vi set blink-matching-paren on in my ~/.inputrc. Activates them in every readline enabled application. Only activating vi command line editing in the shell
answered Aug 25 '10 by maxschlepzig
19
votes
Since back-ticks are often used, it makes sense to teach this syntactic construct. Of course, $() style command substitution should be emphasized as the default style (and standard conforming constru …
answered Jan 21 '15 by maxschlepzig
1
vote
You can do it with find: $ find -maxdepth 1 -not -name subdir -print0 | xargs -0 mv -t subdir Where: -maxdepth 1 restricts the find traversal to the current directory (not a POSIX option, but e.g …
answered Jun 30 '15 by maxschlepzig
9
votes
2answers
Some time ago I used a seq-like tool for printing a sequence of pseudo random generated numbers to stdout. You could specify a range, seed, and the number of samples and much more. I've just forgotte …
asked Aug 24 '10 by maxschlepzig
7
votes
Awk You can adapt the linked pipe in a straight forward way: $ ./script | awk '{ print $NF,$0 }' | sort -k1,1 -n | cut -f2- -d' ' In awk the expression $x references the x-th column of the current …
answered Mar 16 '12 by maxschlepzig
90
votes
You could use find and uniq for this, e.g.: $ find . -type f | sed 's/.*\.//' | sort | uniq -c 16 avi 29 jpg 136 mp3 3 mp4 Command explanation find recursively prints all filenames se …
answered Aug 10 '11 by maxschlepzig
2
votes
The cron daemon usually executes your command in a shell where the PATH environment variable is restricted to some system default, e.g. /usr/bin:/bin. Probably, your php command is not available in …
answered Feb 2 '11 by maxschlepzig
8
votes
shell scripts; that is, except for sharing variables, most elements of an execution environment should behave as if they were a new execution environment, [..] [..] Local variables within a function …
answered Oct 30 '16 by maxschlepzig
10
votes
Yes, there is: $ sort -n file | uniq -c Where -n enables numeric sorting and -c enables counting. For the above sequence: $ echo -e '7\n2\n10\n9\n10\n3\n2\n4\n2\n4\n6' | sort -n | uniq -c 3 2 …
answered Mar 9 '12 by maxschlepzig
3
votes
You have to quote the single quote to protect it from the shell. That means instead of $ cat file.log | awk '{print nir's $1}' you have to write something like $ awk '{print "nir'"'"'s",$1}' file.log …
answered Dec 22 '13 by maxschlepzig
0
votes
3
votes
I don't know why your code does not work for the presented inputs. It does on my system under ksh. But your original code has a problem: the conditional part i<${#aa[@]} is fragile - since ${#aa[@]}, …
answered Jun 23 '13 by maxschlepzig
89
votes
With socat (a 'bidirectional data relay between two data channels') you can connect to the unix domain socket like this: $ socat - UNIX-CONNECT:/tmp/memcached.sock
answered Aug 22 '12 by maxschlepzig
1
vote
Recent bash versions (>= 4) also of associative arrays, i.e. you can also use a bash 'one liner' for it: PATH=$(IFS=:; set -f; declare -A a; NR=0; for i in $PATH; do NR=$((NR+1)); \ if [ \! ${ …
answered Apr 13 '14 by maxschlepzig

15 30 50 per page