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:
It will list all files in your home directory even if your current directory is not home directory
This is a simple command, but useful when you don't remember what episode need to see :D
A short variant if you have only one directory whit only audio files in it.
Finds all cert files on a server and lists them, finding out, which one is a symbolic link and which is true.
You want to do this when a certificate expires and you want to know which files to substitute with the new cert.
Another one.
Maybe not the quicker because of the sort command, but it will also look in other man sections.
updated with goodevilgenius 'shuf' idea
I'm not sure why you would want to do this, but this seems a lot simpler (easier to understand) than the version someone submitted using awk.
Great idea camocrazed. Another twist would be to display a different man page based on the day of the year. The following will continuously cycle through all man pages:
man $(ls /bin | sed -n $(($(date +%j) % $(ls /bin | wc -l)))p)
Broaden your knowledge of the utilities available to you in no particular order whatsoever! Then use that knowledge to create more nifty one-liners that you can post here. =p
Takes a random number modulo the number of files in $dir, prints the filename corresponding to that number, and passes it as an argument to man.
Looks like you're stuck with sed if your ls doesn't have a -Q option.
I had a file named " " (one space) and needed a way to see what the real filename was so I could remove it. sed to the rescue.
all files in the directory get moved, in doing so the new name of the file is the original name with out spaces (using translate command)
All with only one pipe. Should be much faster as well (sort is slow). Use find instead of ls for recursion or reliability.
Edit: case insensitive
If we want files with more than one extension, like .tar.gz, only appear the latest, .gz:
ls -Xp /path/to/dir | grep -Eo "\.[^./]+$" | uniq
'data' is the directory to backup, 'backup' is directory to store snapshots.
Backup files on a regular basis using hard links. Very efficient, quick. Backup data is directly available.
Same as explained here :
http://blog.interlinked.org/tutorials/rsync_time_machine.html
in one line.
Using du to check the size of your backups, the first backup counts for all the space, and other backups only files that have changed.
This version is a bit more portable although it isn't extended as easily with '-type f' etc. On AIX the find command doesn't have -maxdepth or equivalent.
This command, or a derivative like it, is a must-have if you're a server administrator interested in website optimization: https://kinqpinz.info/?%C2%B6=287a7ba6
Command requires Yahoo's YUI, find it here: http://developer.yahoo.com/yui/