Hide

What's this?

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/

Get involved!

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.

World cup college
Hide

Stay in the loop…

Follow the Tweets.

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

Subscribe to the feeds.

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:

Hide

News

2010-03-03 - Commandlinefu @ SXSW 2010
Am going to be at SXSW this year, in case you want to submit any CLI nuggets or suggestions to me in person. Ping me on the @codeinthehole Twitter account.
2009-09-12 - Email updates now available
You can now enable email updates to let you know each time you're command is commented on.
2009-07-11 - API and javascript blog widget now available
A simple API has been released, allowing commands to be retrieved in various formats. This also allows commands to be embedded on blogs/homepages.
2009-05-17 - Added duplicate suggestions to the new command form
When adding a new command, a quick background search is performed to make sure you're not duplicating a command already in the system.
Hide

Tags

Hide

Functions

Commands by vargasmas

Commands by vargasmas from sorted by
Terminal - Commands by vargasmas - 10 results
/usr/bin/links --source http://weather.noaa.gov/pub/data/forecasts/zone/md/mdz009.txt
echo $VARIABLE | xargs -d'\40' -n 6 echo
2010-01-20 15:12:53
User: vargasmas
Functions: echo xargs
2

Print out the contents of $VARIABLE, six words per line, ignoring any single or double quotes in the text. Useful when $VARIABLE contains a sentence that changes periodically, and may or may not contain quoted text.

awk 'BEGIN{while (a++<50) s=s "-"; print s}'
2010-01-06 16:16:35
User: vargasmas
Functions: awk
2

Change the number 50 to whatever number of characters you want. Change the character inside the double quotes to whatever you want printed.

nl <filename>
2010-01-06 16:14:43
User: vargasmas
Functions: nl
1

Works in RHEL5 and derivatives.

<your command here> | perl -n -e 'print "$_" if 1 ... /<regex>/;'
2009-12-22 14:06:41
User: vargasmas
Functions: command perl
1

This command line will display the output of , from the first line of output, until the first time it sees a pattern matching .

You could specify the regex pattern /^$/ to look for the first blank line,

or /^foobar/ to look for the first line that starts with the word foobar.

function man2pdf(){ man -t ${1:?Specify man as arg} | ps2pdf -dCompatibility=1.3 - - > ${1}.pdf; }
2009-11-27 12:49:49
User: vargasmas
Functions: as man
13

Tested on Fedora 12. This function will take a man page and convert it to pdf, saving the output to the current working directory. In Gnome, you can then view the output with "gnome-open file.pdf", or your favorite pdf viewer.

shutdown -rF now
2009-10-05 15:02:36
User: vargasmas
Functions: shutdown
2

Force an fsck on reboot. Useful on a system where / has mounted read-only because of file system issues.

dmidecode | awk '/VMware Virtual Platform/ {print $3,$4,$5}'
2009-09-25 14:46:35
User: vargasmas
Functions: awk
7

If you run this command on a VMWare Virtual Machine, it will return the string "VMware Virtual Platform". If you run it on a physical machine, it will return nothing. Useful for having a script determine if it's running on a VM or not. Of course, you must have dmidecode installed for this to work.

Try it this way in a script: ISVM=$(dmidecode | awk '/VMware Virtual Platform/ {print $3,$4,$5}')

Then test if $ISVM has text in it, or is blank.

badblocks -vfw /dev/fd0 10000 ; reboot
2009-09-04 16:57:51
User: vargasmas
Functions: badblocks
1

THIS COMMAND IS DESTRUCTIVE. That said, lets assume you want to render your boot drive unbootable and reboot your machine. Maybe you want it to boot off the network and kickstart from a boot server for a fresh OS install. Replace /dev/fd0 with the device name of your boot drive and this DESTRUCTIVE command will render your drive unbootable. Your BIOS boot priority should be set to boot from HD first, then LAN.

for x in `seq 0 25 $(curl "http://www.commandlinefu.com/commands/browse"|grep "Terminal - All commands" |perl -pe 's/.+(\d+),(\d+).+/$1$2/'|head -n1)`; do curl "http://www.commandlinefu.com/commands/browse/sort-by-votes/plaintext/$x" ; done > a.txt
2009-08-27 11:02:53
User: vargasmas
Functions: grep head perl
2

'jot' does not come with most *nix distros, so we need to use seq to make it work. This version tested good on Fedora 11.