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:
This will show all changes in all log files under /var/log/ that are regular files and don't end with `gz` nor with a number
-L tells find to follow symbolic links, so -type l will only return links it can't follow (i.e., those that are broken).
May require GNU find.
A simple bash function to the find command. I use this much more than find itself.
Same but will only returns the invalid file (great when emailing the list to the team).
Sometimes I get FLAC files that RhythmBox can't play but VLC can. So I re-encode them using GStreamer at highest compression.
Good for when you download youtube videos and want the mp3 for your mp3 player.
Use case insensitive regex to match files ending in popular video format extensions and calculate their total time. (traverses all files recursively starting from the current directory)
This is a quick way to find what is hogging disk space when you get a full disk alert on your
monitoring system. This won't work as is with filesystems that allow embedded spaces in user
names or groups (read "Mac OS X attached to a Windows Domain"). In those cases, you will need to change the -k 5 to something that works in your situation.
Tired of front end developers using short open tags in your views? This will replace all instances of
Everyone wants to take spaces out of filenames. Forget that. I want to put them back in. We've got tools and filesystems that support spaces, they look better, so I'm going to use them.
Because of how find works I find I need to run this multiple times, if it's renaming subdirs. But it can be re-run without issues.
I got this version of the command from a comment in this underscore-generating command. http://www.commandlinefu.com/commands/view/760/find-recursively-from-current-directory-down-files-and-directories-whose-names-contain-single-or-multiple-whitespaces-and-replace-each-such-occurrence-with-a-single-underscore. All I did was change the regex.
Finds all symbolic links in the specified directory which match the specified string pattern.
I used this when upgrading from an Apple-supported version of Java 6 (1.6.0_65) to an Oracle-supported version (1.7.0_55) on Mac OS X 10.8.5 to find out which executables were pointing to /System/Library/Frameworks/JavaVM.framework/Versions/Current/Commands (Apple version) vs. /Library/Java/JavaVirtualMachines/jdk1.7.0_55.jdk/Contents/Home/bin (Oracle version). However, it appears the current JDK installation script already takes care of modifying the links.
This find syntax seems a little easier to remember for me when I have to use -prune on AIX's find. It works with gnu find, too.
Add whatever other find options after -prune
Convert some SVG files into PNG using ImageMagick's convert command.
Run the conversions in parallel to save time.
This is safer than robinro's forkbomb approach :-)
xargs runs four processes at a time -P4
Deletes files in the current directory or its subdirectories that match "regexp" but handle directories, newlines, spaces, and other funky characters better than the original #13315. Also uses grep's "-q" to be quiet and quit at the first match, making this much faster. No need for awk either.
After this command you can review doit.sh file before executing it.
If it looks good, execute: `. doit.sh`
Finds all nfo files without the filename movie.nfo and deletes them.
find . -maxdepth 1 -iname ".*" | awk 'NR >= 2'
Can be used to list only dotfiles without . nor ..