### All commands (14,042) the last day the last week the last month all time sorted by date votes

• -24
touch balls
· 2009-02-20 19:56:59

• -24
cd
· 2010-08-06 05:33:19

• -24
l
· 2010-09-09 23:26:27

• -24
ls -l ~
· 2010-09-12 10:55:00

• -24
ls -l \$HOME
· 2010-09-12 10:56:13

• -25
ls -la
· 2009-04-13 20:37:25
• Convert Windows/DOS Text Files to Uni Show Sample Output

-26
Convert Windows/DOS Text Files to Uni
· 2009-10-24 18:41:35

• -26
w3m
· 2009-02-20 07:22:07

• -27
perl -e 'print "Hello World!", "\n";'
· 2009-03-24 14:58:01
• This command install Apache 2 and other utilities on CentOS

-31
yum install httpd
· 2009-02-19 16:59:51
• I am using .bat commands to execute Curl commands for Twitter API Show Sample Output

-34
test.bat parm1 parm2 parm3
· 2009-03-25 12:27:18
• Useful to quickly get back to the Windows root directory of the current drive from a sub-directory within that drive. Works also without space between 'cd' and backslash: 'cd\' or 'cd \' have the same effect Show Sample Output

-34
cd \
· 2009-02-14 21:53:51

• -44
ipconfig /all
· 2009-03-06 17:36:07

• -73
· 2009-11-09 20:26:50
• EDIT: Trolling crap removed ;) takes approx 6 secs on a Core 2 Duo @ 2GHz, and 15 secs on atom based netbooks! uses monoid (a,b).(x,y)=(ax+bx+ay,ax+by) with identity (0,1), and recursion relations: F(2n-1)=Fn*Fn+F(n-1)*F(n-1) F(2n)=(Fn+2*F(n-1))*Fn then apply fast exponentiation to (1,0)^n = (Fn,F(n-1)) . Note that: (1,0)^-1=(1,-1) so (a,b).(1,0) = (a+b,a) and (a,b)/(1,0)=(a,b).(1,0)^-1=(b,a-b) So we can also use a NAF representation to do the exponentiation,http://en.wikipedia.org/wiki/Non-adjacent_form , it's also very fast (about the same, depends on n): `time echo 'n=1000000;m=(n+1)/2;a=0;b=1;i=0;while(m>0){z=0;if(m%2)z=2-(m%4);m=(m-z)/2;e[i++]=z};while(i--){c=a*a;a=c+2*a*b;b=c+b*b;if(e[i]>0){t=a;a+=b;b=t};if(e[i]<0){t=a;a=b;b=t-b}};if(n%2)a*a+b*b;if(!n%2)a*(a+2*b)' | bc` Show Sample Output

-134
time echo 'n=1000000;m=(n+1)/2;a=0;b=1;i=0;while(m){e[i++]=m%2;m/=2};while(i--){c=a*a;a=c+2*a*b;b=c+b*b;if(e[i]){t=a;a+=b;b=t}};if(n%2)a*a+b*b;if(!n%2)a*(a+2*b)' | bc
· 2009-09-10 09:00:44
• Calculates nth Fibonacci number for all n>=0, (much faster than matrix power algorithm from http://everything2.com/title/Compute+Fibonacci+numbers+FAST%2521 ) n=70332 is the biggest value at http://bigprimes.net/archive/fibonacci/ (corresponds to n=70331 there), this calculates it in less than a second, even on a netbook. UPDATE: Now even faster! Uses recurrence relation for F(2n), see http://en.wikipedia.org/wiki/Fibonacci_number#Matrix_form n is now adjusted to match Fn at wikipedia, so bigprimes.net table is offset by 1. UPDATE2: Probably fastest possible now ;), uses a simple monoid operation: uses monoid (a,b).(x,y)=(ax+bx+ay,ax+by) with identity (0,1), and recursion relations: F(2n-1)=Fn*Fn+F(n-1)*F(n-1) F(2n)=Fn*(2*F(n-1)+Fn) then apply fast exponentiation to (1,0)^n = (Fn,F(n-1)) . Note that: (1,0)^-1=(1,-1) so (a,b).(1,0) = (a+b,a) and (a,b)/(1,0)=(a,b).(1,0)^-1=(b,a-b) So we can also use a NAF representation to do the exponentiation,http://en.wikipedia.org/wiki/Non-adjacent_form , it's also very fast (about the same, depends on n): `time echo 'n=70332;m=(n+1)/2;a=0;b=1;i=0;while(m>0){z=0;if(m%2)z=2-(m%4);m=(m-z)/2;e[i++]=z};while(i--){c=a*a;a=c+2*a*b;b=c+b*b;if(e[i]>0){t=a;a+=b;b=t};if(e[i]<0){t=a;a=b;b=t-b}};if(n%2)a*a+b*b;if(!n%2)a*(a+2*b)' | bc` Show Sample Output

-135
time echo 'n=70332;m=(n+1)/2;a=0;b=1;i=0;while(m){e[i++]=m%2;m/=2};while(i--){c=a*a;a=c+2*a*b;b=c+b*b;if(e[i]){t=a;a+=b;b=t}};if(n%2)a*a+b*b;if(!n%2)a*(a+2*b)' | bc
· 2009-09-10 08:58:47
• The end of unix time and the 32bit era will be Tue Jan 19 03:14:07 UTC 2038 . `date -ud @\$[2**31]` date: invalid date `@2147483648' . In 64bit you have much longer, at least to: `date -ud @\$[2**55]` `Sun Jun 13 06:26:08 UTC 1141709097` Show Sample Output

-148
date -ud @\$[2**31-1]
· 2009-09-11 08:48:50
• ‹ First  < 560 561 562

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

Edit a script that's somewhere in your path.
Often I need to edit a bash or perl script I've written. I know it's in my path but I don't feel like typing the whole path (or I don't remember the path).

Terminal Keyboard Shortcut list
This command will give you a list of available keyboard shortcuts according to stty.

Fix time-stamped filenames of JPEG images according to the EXIF date the photo was taken
For each *.jpg or *.JPG file in the current directory, extract the date the photo was taken from its EXIF metadata. Then replace the date stamp, which is assumed to exist in the filename, by the date the photo was taken. A trick from https://unix.stackexchange.com/a/9256 is used to split the date into its components.

check open ports without netstat or lsof

Show in a web server, running in the port 80, how many ESTABLISHED connections by ip it has.
The command could show you all conecctions if you skip "grep ESTABLISHED"

Convert seconds to [DD:][HH:]MM:SS
Converts any number of seconds into days, hours, minutes and seconds. sec2dhms() { declare -i SS="\$1" D=\$(( SS / 86400 )) H=\$(( SS % 86400 / 3600 )) M=\$(( SS % 3600 / 60 )) S=\$(( SS % 60 )) [ "\$D" -gt 0 ] && echo -n "\${D}:" [ "\$H" -gt 0 ] && printf "%02g:" "\$H" printf "%02g:%02g\n" "\$M" "\$S" }

Get AWS temporary credentials ready to export based on a MFA virtual appliance
You might want to secure your AWS operations requiring to use a MFA token. But then to use API or tools, you need to pass credentials generated with a MFA token. This commands asks you for the MFA code and retrieves these credentials using AWS Cli. To print the exports, you can use: `awk '{ print "export AWS_ACCESS_KEY_ID=\"" \$1 "\"\n" "export AWS_SECRET_ACCESS_KEY=\"" \$2 "\"\n" "export AWS_SESSION_TOKEN=\"" \$3 "\"" }'` You must adapt the command line to include: * \$MFA_IDis ARN of the virtual MFA or serial number of the physical one * TTL for the credentials

A sorted summary of disk usage including hidden files and folders
Same result as with 'du -ks .[^.]* * | sort -n' but with size outputs in human readable format (e.g., 1K 234M 2G)

Convert CSV to JSON

### Stay in the loop…  