commandlinefu.com is the place to record those command-line gems that you return to again and again.
Delete that bloated snippets file you've been using and share your personal repository with the world. 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.
If you have a new feature suggestion or find a bug, please get in touch via http://commandlinefu.uservoice.com/
You can sign-in using OpenID credentials, or register a traditional username and password.
First-time OpenID users will be automatically assigned a username which can be changed after signing in.
Every new command is wrapped in a tweet and posted to Twitter. Following the stream is a great way of staying abreast of the latest commands. For the more discerning, there are Twitter accounts for commands that get a minimum of 3 and 10 votes - that way only the great commands get tweeted.
» http://twitter.com/commandlinefu
» http://twitter.com/commandlinefu3
» http://twitter.com/commandlinefu10
Use your favourite RSS aggregator to stay in touch with the latest commands. There are feeds mirroring the 3 Twitter streams as well as for virtually every other subset (users, tags, functions,…):
Subscribe to the feed for:
If you want a sequence that can be plotted, do:
seq 8 | awk '{print "e(" $0 ")" }' | bc -l | awk '{print NR " " $0}'
Other bc functions include s (sine), c (cosine), l (log) and j (bessel). See the man page for details.
The biggest advantage over atoponce's nifty original is not killing the scrollback. Written assuming bash, but shouldn't be terribly difficult to port to other shells. S should be multiple spaces, but I can't get commandlinefu to save/show them properly, any help?
Simple countdown clock that should be quite portable across any Bourne-compatible shell. I used to teach for a living, and I would run this code when it was time for a break. Usually, I would set "MIN" to 15 for a 15-minute break. The computer would be connected to a projector, so this would be projected on screen, front and center, for all to see.
Print a row of characters across the terminal. Uses tput to establish the current terminal width, and generates a line of characters just long enough to cross it. In the example '#' is used.
It's possible to use a repeating sequence by dividing the columns by the number of characters in the sequence like this:
seq -s'~-' 0 $(( $(tput cols) /2 )) | tr -d '[:digit:]'
or
seq -s'-~?' 0 $(( $(tput cols) /3 )) | tr -d '[:digit:]'
You will lose chararacters at the end if the length isn't cleanly divisible.
Will create a graph of the results for "x bottles of beer on the wall".
Requires Gnuplot.
Inspired by an xkcd comic: http://xkcd.com/715/
For sample output see: http://tr.im/xbottlesofbeer
The loop is to compare cookies. You can remove it...
Maybe you wanna use curl...
curl www.commandlinefu.com/index.php -s0 -I | grep "Set-Cookie"
Parallel is from https://savannah.nongnu.org/projects/parallel/
Other examples would be:
(echo foss.org.my; echo www.debian.org; echo www.freenetproject.org) | parallel traceroute
seq -f %04g 0 9999 | parallel -X rm pict{}.jpg
With counter format [001, 002, ..., 999] , nice with pictures or wallpapers collections.
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.
uses the previous "chr" function and uses it to create the inverse function "ord" by brute force.
It's slow, It's inelegant, but it works.
I thought I needed ord/chr to do a cartesian cipher in shell script a whie ago, but eventualy I realized I could get fancy with tr and do the same thing...
This command generates a sequential login list. Good to be used as a source of new logins.
Nice command to create a list, you can create too with for command, but this is so faster.
Intentional hash in the beginning. May run a looong time. Wipes your data for real. Was meant to be /dev/urandom - I mistyped it. :-)
After this, just type:
beepwhenup
You need to install "beep" before this would make the beep sound.
Save it in your .profile if you want to use it later
WARNING: this command won't exit until it is successful. You won't be able to CONTROL+C out of it.
Strangely enough, there is no option --lines=[negative] with tail, like the head's one, so we have to use sed, which is very short and clear, you see.
Strangely more enough, skipping lines at the bottom with sed is not short nor clear. From Sed one liner :
# delete the last 10 lines of a file
$ sed -e :a -e '$d;N;2,10ba' -e 'P;D' # method 1
$ sed -n -e :a -e '1,10!{P;N;D;};N;ba' # method 2
print multiple increasing years using cal - calendar -. You can also try
seq Start Increment End
Depending on the installation only certain of these man pages are installed. 12 is left out on purpose because ISO/IEC 8859-12 does not exist. To also access those manpages that are not installed use opera (or any other browser that supports all the character sets involved) to display online versions of the manpages hosted at kernel.org:
for i in $(seq 1 11) 13 14 15 16; do opera http://www.kernel.org/doc/man-pages/online/pages/man7/iso_8859-$i.7.html; done