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:
Enhancement for the 'busy' command originally posted by busybee : less chars, no escape issue, and most important it exclude small files ( opening a 5 lines file isn't that persuasive I think ;) )
This makes an alias for a command named 'busy'. The 'busy' command opens a random file in /usr/include to a random line with vim.
calls grep on all non-binary files returned by find on its current working directory
Requires ImageMagick to be installed.
This command was stolen from @climagic on Twitter.
Probably a duplicate of command below, but this command uses slightly higher quality.
It does not work without the verbose mode (-v is important)
Sort by time and Reverse to get Ascending order, then display a marker next to the a file, negate directory and select only 1 result
Find which directories on your system contain a lot of files.
Edit: much shorter and betterer with -n switch.
This command will give you the same list of files as "find /etc/ -name '*killall' | xargs ls -l".
In a simpler format just do 'ls /etc/**/file'.
It uses shell globbing, so it will also work with other commands, like "cp /etc/**/sshd sshd_backup".
-sl : show just file names
Find all files in /var/spool/mqueue older than 7 days, pass to perl to efficiently delete them (faster than xargs or -exec when you've got millions or hundreds of thousands to delete). Naturally the type, directory, and file age vars can be adjusted to meet your specific needs.
Videos are found using their MIME type. Thus no need to for an extension for the video file.
This is a efficent version of "jnash" cmd (4086). Thanks for jnash. This cmd will only show video files while his cmd show files having "video" anywhere in path.
Change "sort -f" to "sort" and "uniq -ic" to "uniq -c" to make it case sensitive.
Tells you everything you could ever want to know about all files and subdirectories. Great for package creators. Totally secure too.
On my Slackware box, this gets set upon login:
LS_OPTIONS='-F -b -T 0 --color=auto'
alias ls='/bin/ls $LS_OPTIONS'
which works great.
ls -F | grep /\$
but will break on directories containing newlines. Or the safe, POSIX sh way (but will miss dotfiles):
for i in *; do test -d "./$i" && printf "%s\n" "$i"; done
.flac is the filetype.
/Volumes/Music/FLAC is the destination.
Replace .py with .rb or .java to get the LOC of that particular filetype. An alternative is http://www.commandlinefu.com/commands/view/2812/make-a-statistic-about-the-lines-of-code
Specify the size in bytes using the 'c' option for the -size flag. The + sign reads as "bigger than". Then execute du on the list; sort in reverse mode and show the first 10 occurrences.
Prints the path/filename and sparseness of any sparse files (files that use less actual space than their total size because the filesystem treats large blocks of 00 bytes efficiently).
There's nothing particularly novel about this combination of find, grep, and wc, I'm just putting it here in case I want it again.
ack search recursively by default