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:
Finds all files recursively from your working directory, matching 'aMethodName', except if 'target' is in that file's path.
Handy for finding text without matching all your files in target or subversion directories.
To understand why this is the equivalent of "find -L /path/to/search -type l, see http://ynform.org/w/Pub/FindBrokenSymbolicLinks or look at http://www.gnu.org/software/findutils/manual/html_mono/find.html
From the cwd, recursively find all rar files, extracting each rar into the directory where it was found, rather than cwd.
A nice time saver if you've used wget or similar to mirror something, where each sub dir contains an rar archive.
Its likely this can be tuned to work with multi-part archives where all parts use ambiguous .rar extensions but I didn't test this. Perhaps unrar would handle this gracefully anyway?
Also shows files as they are found. Only works from a tty.
This command finds all the files whose status has changed between the ctime of the older and newer .
Very useful if you can see from an ls listing a block of consecutive files you want to move or delete, but can't figure out exactly the time range by date.
These should be a little faster since they don't have to spawn grep.
My most used bash function without a doubt!
This sorts files in multiple directories by their modification date. Note that sorting is done at the end using "sort", instead of using the "-ltr" options to "ls". This ensures correct results when sorting a large number of files, in which case "find" will call "ls" multiple times.
Like the above, but runs a single rm command
This requires a version of GNU find that supports the -exec {} + action, but it seems more straightforward than the versions already posted.
suspicious/anomalous ownership may indicate system breach; should return no results
rm /SOME/PATH/*, when you hit "argument list too long".
Handles spaces in file names and directories. Optionally change directories as well by pipe to tr from dirname.
Using `-exec cmd {} +` causes find to build the command using all matching filenames before execution, rather than once per file.
This is much safer than using -L, because it will not follow links that point to places outside the target directory subtree (CWD, in this case). See here for explanation: http://unix.stackexchange.com/a/38691/9382
This command won't delete resource forks from an HFS file system, only from file systems that don't natively support resource forks.
When downloading files on a Mac, Apple adds the x-attribute: com.apple.quarantine. Often, this makes it so you can't even run a ./configure. This command gets rid of the quarantine for all files in the current directory.
works only in zsh, requires EXTENDED_GLOB to be set.