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:
Commandline perl filter for, using a production.log from a rails app, display on realtime the count of requests grouped by "seconds to complete" (gross round, but fair enough for an oneliner) :)
Just want to post a Perl alternative.
Does not count hidden files ('.' ones).
Requires perl 5.14 or greater
- excel date compatible with a separate hour field
- added a fixed 1 for easier request counter aggregation
- split URL in directory, filename, fileext, query
- used with tomcat valve with response bytes replaced by elapsed time
This one line Perl script will display the smallest to the largest files sizes in all directories on a server.
The crypt function takes a password, key, as a string, and a salt character array which is described below, and returns a printable ASCII string which starts with another salt. It is believed that, given the output of the function, the best way to find a key that will produce that output is to guess values of key until the original value of key is found.
If you don't have seq, you can use perl.
Easily removes line #2 in ~/.ssh/known_hosts.
Search in decimal rather than hex. od dumps the character list, cut to remove offsets, sort -u gives the used characters. seq gives the comparison list, but we need this sorted alphabetically for comm, which does the filtering. I drop to perl to convert back to characters (is there a better way?) and then use od to dump them in a print-safe format.
A different approach to the problem - maintain a small sorted list, print the largest as we go, then the top 10 at the end. I often find that the find and sort take a long time, and the large file might appear near the start of the find. By printing as we go, I get better feedback. The sort used in this will be much slower on perls older than 5.8.
Here's a perl version that only considers printable characters. Change the regex /[[:print:]]/ to look for different sets of delimiter characters.
This is especially useful to get crazy stuff like space characters copied to your pasteboard correctly.
Removes special characters (colors) in '^]]Xm' and '^]]X;Ym' format from file.
Use pipe ('input | perl [...]') or stream ('perl [...]
You can use 'cat -v infile' as 'input' to show special characters instead of interpreting (there is problem with non-ASCII chars, they are replaced by M-[char]).
This will also print the path to file which is not included in the other examples.
parse `lsmod' output and pass to `dot' drawing utility then finally pass it to an image viewer
This will create a new file with proper code formatting and all comments removed.
convert a unix timestamp to a human readable format.
Lists all the modules that were installed the "proper way". It also uses Perl 5.10(or higher)'s say command for less typing.
making it "sound" more "natural" language like -- additionally sorting the longest words alphabetically:
this approach is using:
* to get at all lines of input
* post-"for" structure
* short-circuit-or in sort: if the lengths are the same, then sort alphabetically otherwise don't even evaluate the right hand side of the or
* -C sets all input and ouput channels to utf8