Sort ‘ls’ output by name

My ls sorts by name by default. What are you seeing? man ls states: List information about the FILEs (the current directory by default). Sort entries alphabetically if none of -cftuvSUX nor –sort is specified.

How can I add a help method to a shell script?

here’s an example for bash: usage=”$(basename “$0″) [-h] [-s n] — program to calculate the answer to life, the universe and everything where: -h show this help text -s set the seed value (default: 42)” seed=42 while getopts ‘:hs:’ option; do case “$option” in h) echo “$usage” exit ;; s) seed=$OPTARG ;; 🙂 printf “missing … Read more

Force line-buffering of stdout in a pipeline

you can try stdbuf $ stdbuf –output=L ./a | tee output.txt (big) part of the man page: -i, –input=MODE adjust standard input stream buffering -o, –output=MODE adjust standard output stream buffering -e, –error=MODE adjust standard error stream buffering If MODE is ‘L’ the corresponding stream will be line buffered. This option is invalid with standard … Read more

Command-line Unix ASCII-based charting / plotting tool

Try gnuplot. It has very powerful graphing possibilities. It can output to your terminal in the following way: gnuplot> set terminal dumb Terminal type set to ‘dumb’ Options are ‘feed 79 24’ gnuplot> plot sin(x) 1 ++—————-**—————+—-**———–+——–**—–++ + *+ * + * * + sin(x) ****** + 0.8 ++ * * * * * * … Read more