### Commands tagged graph (7) the last day the last week the last month all time sorted by date votes

• Useful when you've produced a large file of numbers, and want to quickly see the distribution. The value of y halfway along the x axis is the median. Simple! Just create the listOfNumbers.txt file with a number on each line to try it out.

23
gnuplot -persist <(echo "plot '<(sort -n listOfNumbers.txt)' with lines")
· 2009-05-02 13:46:02
• A more efficient way, with reversed order to put the focus in the big ones. Show Sample Output

12
du -x --max-depth=1|sort -rn|awk -F / -v c=\$COLUMNS 'NR==1{t=\$1} NR>1{r=int(\$1/t*c+.5); b="\033[1;31m"; for (i=0; i<r; i++) b=b"#"; printf " %5.2f%% %s\033[0m %s\n", \$1/t*100, b, \$2}'|tac
· 2015-09-12 10:36:49
• Will track your mouse and save it to a file. You can use gnuplot to graph it: `gnuplot -persist <(echo "unset key;unset border;unset yzeroaxis;unset xtics;unset ytics;unset ztics;plot './mouse-tracking' with points lt 1 pt 6 ps variable")`

4
while true; do xdotool getmouselocation | sed 's/x:\(.*\) y:\(.*\) screen:.*/\1, \2/' >> ./mouse-tracking; sleep 10; done
· 2010-02-27 04:00:13
• Sometimes jittery data hides trends, performing a rolling average can give a clearer view.

3
awk 'BEGIN{size=5} {mod=NR%size; if(NR<=size){count++}else{sum-=array[mod]};sum+=\$1;array[mod]=\$1;print sum/count}' file.dat
· 2009-05-29 00:07:24
• See: http://imgur.com/JgjK2.png for example. Do some serious benchmarking from the commandline. This will write to a file with the time it took to compress n bytes to the file (increasing by 1). Run: `gnuplot -persist <(echo "plot 'lzma' with lines, 'gzip' with lines, 'bzip2' with lines")` To see it in graph form.

3
for a in bzip2 lzma gzip;do echo -n>\$a;for b in \$(seq 0 256);do dd if=/dev/zero of=\$b.zero bs=\$b count=1;c=\$(date +%s%N);\$a \$b.zero;d=\$(date +%s%N);total=\$(echo \$d-\$c|bc);echo \$total>>\$a;rm \$b.zero *.bz2 *.lzma *.gz;done;done
· 2009-10-20 01:00:51
• The arguments of "seq" indicate the starting value, step size, and the end value of the x-range. "awk" outputs (x, f(x)) pairs and pipes them to "graph", which is part of the "plotutils" package.

2
seq 0 0.1 20 | awk '{print \$1, cos(0.5*\$1)*sin(5*\$1)}' | graph -T X
· 2009-03-24 21:46:59
• Nasty perl one-liner that provides a sparkline of ping times. If you want a different history than the last 30, just put that value in. It (ab)uses unicode to draw the bars, inspired by https://github.com/joemiller/spark-ping . It's not the most bug-free piece of code, but what it lacks in robustness it makes up for in capability. :) If anyone has any ideas on how to make it more compact or better, I'd love to hear them. I included a ping to google in the command just as an example (and burned up 10 chars doing it!). You should use it with: \$ ping example.com | \$SPARKLINE_PING_COMMAND Show Sample Output

2
ping g.co|perl -ne'\$|=/e=(\S+)/||next;(push@_,\$1)>30&&shift@_;print"\r",(map{"\xe2\x96".chr(128+7*\$_/(sort{\$b<=>\$a}@_)[0])." "}@_),"\$1ms"'
· 2012-07-06 22:42:06

### What's this?

commandlinefu.com is the place to record those command-line gems that you return to again and again. That way others can gain from your CLI wisdom and you from theirs too. All commands can be commented on, discussed and voted up or down.

### Check These Out

git pull all repos

Shows users and 'virtual users' on your a unix-type system
Shows a list of users that currently running processes are executing as. YMMV regarding ps and it's many variants. For example, you might need: \$ ps -axgu | cut -f1 -d' ' | sort -u

send incoming audio to a Icecast server (giss.tv)
easy way to setup an "internet radio sation", pre-requisite, create an account at an icecast server, in this example, just created beforehand an account at giss.tv. Change the word password, with the respective real password you created at server. Make sure to have installed rec, oggnec, oggfwd and tee. I have a mixer connected at line in, so I can mix music and microphone. This also will produce a local recorded copy of the session, it will be called "streamdump.ogg"

I prefer the ip command to ifconfig as ifconfig is supposedly going to be deprecated. Certain IP address aliases can only be seen with the ip command (such as the ones applied by RHCS).

find text in a file
this will find text in the directory you specify and give you line where it appears.

Convert JSON to YAML

randomize hostname and mac address, force dhcp renew. (for anonymous networking)
this string of commands will release your dhcp address, change your mac address, generate a new random hostname and then get a new dhcp lease.

Based on capsule8 agent examples, not rigorously tested

[UPDATE: Now works for multiple connected outputs] I woke up around midnight with an urge to do some late night hacking, but I didn't want a bright monitor screwing up my body's circadian rhythm. I've heard that at night blue (short wavelength) lights are particularly bad for your diurnal clock. That may be a bunch of hooey, but it is true that redder (longer wavelength) colors are easier on my eyes at night. This command makes the screen dimmer and adjusts the gamma curves to improve contrast, particularly darkening blues and greens (Rɣ=2, Gɣ=3, Bɣ=4). To reset your screen to normal, you can run this command: \$ xrandr | sed -n 's/ connected.*//p' | xargs -n1 -tri xrandr --output {} --brightness 1 --gamma 1:1:1 or, more briefly, \$ xgamma -g 1 Note: The sed part is fragile and wrong. I'm doing it this way because of a misfeature in xrandr(1), which requires an output be specified but has no programmatic way of querying available outputs. Someone needs to patch up xrandr to be shell script friendly or at least add virtual outputs named "PRIMARY" and "ALL". . Todo: Screen should dim (gradually) at sunset and brighten at sunrise. I think this could be done with a self-resubmitting at job, but I'm running into the commandlinefu 127 character limit just getting the sunrise time: \$ wget http://aa.usno.navy.mil/cgi-bin/aa_pap.pl --post-data=\$(date "+xxy=%Y&xxm=%m&xxd=%d")"&st=WA&place=Seattle" -q -O- | sed -rn 's/\W*Sunrise\W*(.*)/\1/p' I hope some clever hacker comes up with a command line interface to Google's "OneBox", since the correct time shows up as the first hit when googling for "sunrise:cityname". . [Thank you to @flatcap for the sed improvement, which is much better than the head|tail|cut silliness I had before. And thank you to @braunmagrin for pointing out that the "connected" output may not be on the second line.]

Deleting / Ignoring lines from the top of a file
Output lines starting at line 2.