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:
Today I needed a way to print various character classes to use as input for a program I was writing. Also a nice way to visualize character classes.
Parse the output of git status.
Once the line '# Changed but not updated:' has passed print every last part of the line if it exists on disk.
**NOTE** Tekhne's alternative is much more succinct and its output conforms to the files actual contents rather than with white space removed
My command on the other hand uses bash process substitution (and "Minimal" Perl), instead of files, to first remove leading and trailing white space from lines, before diff'ing the streams. Very useful when differences in indentation, such as in programming source code files, may be irrelevant
This deals nicely with filenames containing special characters and can deal with more files than can fit on a commandline. It also avoids spawning du.
This will show you any links that a command follows (unlike 'file -L'), as well as the ultimate binary or script.
Put the name of the command at the very end; this will be passed to perl as the first argument.
For obvious reasons, this doesn't work with aliases or functions.
Just use "od" and it can also dump in decimal or octal.
(use -t x1 and not just -x or it confuses the byte order)
There is a load of other formatting options, I'm not sure if you can turn off the address at the start of the line.
Here's a version that uses perl. If you'd like a trailing newline:
perl -pe 's/(.)/sprintf("\\x%x", ord($1))/eg; END {print "\n"}'
Print "Art of hacking..." 100 times by perl
or you can this tools : http://packetstormsecurity.org/shellcode/shellcodeencdec.py.txt
Replaces tabs in output with spaces. Uses perl since sed seems to work differently across platforms.
Requires Net::Twitter. Just replace the double quoted strings with the appropriate info.
Finds all *.p[ml]-files and runs a perl -c on them, checking whether Perl thinks they are syntactically correct
Solaris 'ls' command does not have a nice '--full-time' arg to make the time show after a year has passed. So I spit this out quick. It hates spaces in file names.
Of course you will have to install Digest::SHA and perl before this will work :)
Maximum length is 43 for SHA256. If you need more, use SHA512 or the hexadecimal form: sha256_hex()
This command will give you the detailed information about the installed perl modules i.e. installed path, Link type, version, files etc.
you can use xmlstarlet to parse output instead of perl
In this example, file contains five columns where first column is text. Variance is calculated for columns 2 - 5 by using perl module Statistics::Descriptive. There are many more statistical functions available in the module.
This method will also convert mac line endings.