### Commands by kaan (6) the last day the last week the last month all time sorted by date votes

• 6
awk '{sum+=\$1; sumsq+=\$1*\$1} END {print sqrt(sumsq/NR - (sum/NR)**2)}' file.dat
· 2009-03-24 21:56:40
• 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
• Displays six rows and five columns of random numbers between 0 and 1. If you need only one column, you can dispense with the "for" loop. Show Sample Output

3
seq 6 | awk '{for(x=1; x<=5; x++) {printf ("%f ", rand())}; printf ("\n")}'
· 2009-03-24 21:33:38
• This example calculates the averages of column one and column two of "file.dat". It can be easily modified if other columns are to be averaged.

2
awk '{sum1+=\$1; sum2+=\$2} END {print sum1/NR, sum2/NR}' file.dat
· 2009-03-24 21:22:14
• Another combination of seq and awk. Not very efficient, but sufficiently quick. Show Sample Output

14
seq 50| awk 'BEGIN {a=1; b=1} {print a; c=a+b; a=b; b=c}'
· 2009-03-24 20:39:24
• "seq 100" outputs 1,2,..,100, separated by newlines. awk adds them up and displays the sum. "seq 1 2 11" outputs 1,3,..,11. Variations: 1+3+...+(2n-1) = n^2 `seq 1 2 19 | awk '{sum+=\$1} END {print sum}' # displays 100` 1/2 + 1/4 + ... = 1 `seq 10 | awk '{sum+=1/(2**\$1)} END {print sum}' # displays 0.999023` Show Sample Output

4
seq 100 | awk '{sum+=\$1} END {print sum}'
· 2009-03-24 20:30:40

### 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

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.

Stop Flash from tracking everything you do.
Brute force way to block all LSO cookies on a Linux system with the non-free Flash browser plugin. Works just fine for my needs. Enjoy.

Get last sleep time on a Mac
Similarly for last wake time: \$ sysctl -a | grep waketime

Check for login failures and summarize
This command checks for the number of times when someone has tried to login to your server and failed. If there are a lot, then that user is being targeted on your system and you might want to make sure that user either has remote logins disabled, or has a strong password, or both. If your output has an "invalid" line, it is a summary of all logins from users that don't exist on your system.

Creates a quick backup with tar to a remote host over ssh.

Convert mysql database from latin1 to utf8
MySQL: CHARSET from latin1 to utf8

Find the package that installed a command

List all the files that have been deleted while they were still open.
If your customer deletes a file that is still in use by a process, that space does not get freed up (will not show up in df) until that process either closes the file on its own, or is killed.

Simple Comment an entire file
With this simple sed command we can easily comment and entire file.

Show exit status of all portions of a piped command eg. ls |this_doesn't_exist |wc