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.
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:
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).
gnuplot -persist <(echo "plot 'lzma' with lines, 'gzip' with lines, 'bzip2' with lines")
To see it in graph form.
This is a quick and easy way of encrypting files in a datastream, without ever really creating an output file from gpg. Useful with cron also, when file(s) have to be sent based on a set schedule.
Use the hold space to preserve lines until data is needed.
I don't know if it's better but works fine :)
List packages and their disk usage in decreasing order. This uses the "Installed-Size" from the package metadata. It may differ from the actual used space, because e.g. data files (think of databases) or log files may take additional space.
Copying only wmv and mpg files recursively from to
I use it for embedding images in CSS for Stylish, the Firefox addon.
Thought it might be useful to others.
I often need to extract a function from a bash script and this command will do it.
This time I added a print to reemaining energy, every minute, time stamped.
The example shown here is complete and point to large discrepancies as time passes, converging to accuracy near the end.
Sample command to obtain a list of geographic localization for established connections, extracted from netstat. Need geoiplookup command ( part of geoip package under CentOS)
Fully recharge your computer battery and start this script.
It will create or clean the file named battery.txt, print a start on it and every minute it will append a time stamp to it.
Batteries last few hours, and each hour will have 60 lines of time stamping. Really good for assuring the system was tested in real life with no surprises.
The last time stamp inside the battery.txt file is of interest. It is the time the computer went off, as the battery was dead!
Turn on your computer after that, on AC power of course, and open battery.txt. Read the first and last time stamps and now you really know if you can trust your computer sensors.
If you want a simple line of text inside the battery.txt file, use this:
watch -n 60 'date > battery.txt'
The time of death will be printed inside
Scrape the National Weather Service
printf treats first char after single ' as numeric equivalent
create iso image from directory . Usefull for virtualised machine
To create CD ISO image of directories that contain long file name or non-8.3 format (particularly if you want to burn the CD image for use in Windows system), use the -J option switch that generates Joliet directory records in addition to regular iso9660 file names. For example, to create CD image of Vista SP1 directory: mkisofs -o VitaSP1.iso -J VistaSP1
the shortest command for character 'a' i know
Doesn't fail for percent sign now.
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...
Really useful way to combine less and grep while browsing log files.
I can't figure out how to make it into a true oneliner so paste it into a script file called lgrep:
lgrep searchfor file1 [file2 file3]
Advanced example (grep for an Exception in logfiles that starts with qc):
lgrep Exception $(find . -name "qc*.log")
Note the space before the command; that prevents your history eliminating command from being recorded. ' history -c && rm -f ~/.bash_history' Both steps are needed. 'history -c' clears what you see in the history command. 'rm -f ~/.bash_history' deletes the history file in your home directory.