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:
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 ..
I tried a few curses based mp3 players for playing back choir practice songs for my wife.
Unfortunately none of the ones I tried were capable of scrubbing a track.
Firefox saves the day.
Btrfs reports the inode numbers of files with failed checksums. Use `find` to lookup the file names of those inodes. The files may need to be deleted and replaced with backups.
shows you the symlinks in the current directory, recursively, but without following them
Btrfs reports the inode numbers of files with failed checksums. Use `find` to lookup the file names of those inodes.
Does a search and replace across multiple files with a subgroup replacement.
Very quick! Based only on the content sizes and the character counts of filenames. If both numbers are equal then two (or more) directories seem to be most likely identical.
if in doubt apply:
diff -rq path_to_dir1 path_to_dir2
AWK function taken from here:
This command will traverse all of the folders and subfolders under current working directory. For every file inside it, it will do a search inside the content of the file for a specific term 'what'. Then it will print a list of the lines that contain that term (and match that pattern). Each matching line will be preceded with the path and name to the file and then the line number iside taht file wehre the pattern was found. Then the actual content of the matching lien will be printed.
The output will be piped throug less, so that the user can scroll through it if it goes beyond the limits of the current display window.
If you need to find some pictures on your disk but excluding some path.
recurse through all files, get the message hash, flip the output as filename, hash value
Use find's built-in "exec" option to avoid having to do any weirdness with quoting.
Will move in that case every file in the current folder older than 30 days to the "old" folder
Replace "mv $i old/" by any command such as rm / echo to do something different.
This command uses -newerXY to show you the files that are modified since a specific date. I recommend looking for "-newerXY" on the manpage to get the specifics.