commandlinefu.com is the place to record those command-line gems that you return to again and again.
You can sign-in using OpenID credentials, or register a traditional username and password.
Subscribe to the feed for:
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.
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.
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.
Save some CPU, and some PIDs. :)
Seeing that _sort_ its been used, why not just _use_ it. ;)
sort command can sort month-wise (first three letters of each month).
See the sample output for clarification.
Sorting Stable ? NO. Take note if that matters to you.
Sample output suggests that sort performs unstable
sorting (see the relative order of two 'feb' entries).
In this case I'm just grabbing the next level of subdirectories (and same level regular files) with the --max-depth=1 flag. leaving out that flag will just give you finer resolution. Note that you have to use the -h switch with both 'du' and with 'sort.'
as per eightmillion's comment.
Simply economical :)
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.
If both file1 and file2 are already sorted:
comm -13 file1 file2 > file-new
Find which directories on your system contain a lot of files.
Edit: much shorter and betterer with -n switch.
PmWiki stores wiki pages as Group.Name. Simply split the directory listing and count frequency of group occurances.
(separator = $IFS)
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.
If your version of curl does not support the --compressed option, use
curl -s http://funnyjunk.com | gunzip
curl -s --compressed http://funnyjunk.com
Randomizes a file. The opposite of sort is sort -R!
count connections, group by IP and port
List all MAC addresses on a Linux box. sort -u is useful when having virtual interfaces.
Sort lines within vi editor. In this example sort lines 33-61 and lines 4-9 asciibetically.
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!