Gives the same results as the command by putnamhill using nine less characters.
Credit goes to brun65i but he posted it as a comment instead as an alternative. I hadn't noticed the -h option on sort before and this seems like the cleanest alternative. Thanks Brun65i! Show Sample Output
count connections, group by IP and port
If your version of curl does not support the --compressed option, use
curl -s http://funnyjunk.com | gunzip
instead of
curl -s --compressed http://funnyjunk.com
Find which directories on your system contain a lot of files. Edit: much shorter and betterer with -n switch. Show Sample Output
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.
Tested in bash on AIX & Linux, used for WAS versions 6.0 & up. Sorts by node name. Useful when you have vertically-stacked instances of WAS/Portal. Cuts out all the classpath/optional parameter clutter that makes a simple "ps -ef | grep java" so difficult to sort through. Show Sample Output
See who is using a specific port. Especially when you're using AIX. In Ubuntu, for example, this can easily be seen with the netstat command. Show Sample Output
Take a file and ,."()?!;: give a list of all the words in order of increasing length. First of all use tr to map all alphabetic characters to lower case and also strip out any puntuation. A-Z become a-z ,."()?!;: all become \n (newline) I've ignored - (hyphen) and ' (apostrophe) because they occur in words. Next use bash to print the length ${#w} and the word Finally sort the list numerically (sort -n) and remove any duplicates (sort -u). Note: sort -nu performs strangely on this list. It outputs one word per length. Show Sample Output
here's a version which works on OS X.
cut -f1,2 - IP range 16 cut -f1,2,3 - IP range 24 cut -f1,2,3,4 - IP range 24 Show Sample Output
Sort using kth column using : delimiter
ls -al gives all files, sort +4n sorts by 5th field numerically
Uniq command is mostly used in combination with sort command, as uniq removes duplicates only from a sorted file. i.e In order for uniq to work, all the duplicate entries should be in the adjacent lines. Show Sample Output
The following displays only the entries that are duplicates. Show Sample Output
This requires a version of GNU find that supports the -exec {} + action, but it seems more straightforward than the versions already posted. Show Sample Output
"-exec" ftw.
Count on a specific port (80) - FreeBSD friendly. Show Sample Output
the -h option of du and sort (on appropriate distrib) makes output "Human" readable and still sorted by "reversed size" (sort -rh) Show Sample Output
This is a modified version of the OP, wrapped into a bash function. This version handles newlines and other whitespace correctly, the original has problems with the thankfully rare case of newlines in the file names. It also allows checking an arbitrary number of directories against each other, which is nice when the directories that you think might have duplicates don't have a convenient common ancestor directory.
If you have GNU findutils, you can get only the file name with
find /some/path -type f -printf '%f\n'
instead of
find /some/path -type f | gawk -F/ '{print $NF}'
Show Sample Output
bit of a contrived example and playing to my OCD but nice for quick scripted output of listening ports which is sorted by port, ip address and protocol. Show Sample Output
commandlinefu.com is the place to record those command-line gems that you return to again and again. 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.
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: