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:
If you're like me and want to keep all your music rated, and you use xmms2, you might like this command.
I takes 10 random songs from your xmms2 library that don't have any rating, and adds them to your current playlist. You can then rate them in another xmms2 client that supports rating (I like kuechenstation).
I'm pretty sure there's a better way to do the grep ... | sed ... part, probably with awk, but I don't know awk, so I'd welcome any suggestions.
Declare this function in your Shell, then use it like this:
> jumpTo foo
The script will search for the 'foo' pattern in your current xmms2 playlist (artist or songname), and play the first occurence of it !
Does that count as a win for bzip2?
This little command (function) shows the CSV header fields (which are field names separated by commas) as an ordered list, clearly showing the fields and their order.
Coming back to a project directory after sometime elsewhere?
Need to know what the most recently modified files are?
This little function "t" is one of my most frequent commands.
I have a tcsh alias for it also:
alias t 'ls -ltch \!* | head -20'
Replace < pw-length > with the desired password-length.
The password-length is not always correct, but wayne...
You need curl.. and a Mac of course.
Low on disk space? Check the largest installed RPMs for delete canditates.
Suppose you made a backup of your hard disk with dd:
dd if=/dev/sda of=/mnt/disk/backup.img
This command enables you to mount a partition from inside this image, so you can access your files directly.
Substitute PARTITION=1 with the number of the partition you want to mount (returned from sfdisk -d yourfile.img).
Deletes thousands of files at one go, I'm not able to recall the exact # of files that rm can delete at one go(apprx. around 7000.)
If you want a password length longer than 6, changing the -c6 to read -c8 will give you 8 random characters instead of 6. To end up with a line-feed, use this with echo:
# echo `< /dev/urandom tr -dc _A-Z-a-z-0-9 | head -c6`
Pump up the chatter, run this script on a regular basis to listen to your twitter timeline.
This is a rough first cut using several cli clips I have spotted around. There is no facility to not read those things already read to you. This could also easily be put in a loop for timed onslaught from the chatterverse, though I think it might violate several pointsof the Geneva Convention
UPDATE - added a loop, only reads the first 6 twits, and does this every 5 mins.
This will give you the Dell Service tag number associated with your machine. Incredibly useful when you need that number for tech support or downloads.
Find random strings within /dev/urandom. Using grep filter to just Alphanumeric characters, and then print the first 30 and remove all the line feeds.
tells you the number of lines in said file, and then tail the last 100 lines ( or how many are messed up) then u take the total amount of lines and then subract the 100 or so lines u DONT WANT, then do a head -n $new_number and then redirect it to new file.db
while [ 1 -ne 6 ]; do
pid=`ps -ef | grep -v "grep" | grep "trans_gzdy" | cut -c10-17`
ps gv $pid | head -2
check changes of RSS.
Useful for massive files where doing a full diff would take too long. This just runs diff on the first 500 lines of each. The use of subshells to feed STDIN is quite a useful construct.