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:
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!
Show disk space info, grepping out the uninteresting ones beginning with ^none while we're at it.
The main point of this submission is the way it maintains the header row with the command grouping, by removing it from the pipeline before it gets fed into the sort command. (I'm surprised sort doesn't have an option to skip a header row, actually..)
It took me a while to work out how to do this, I thought of it as I was drifting off to sleep last night!
Select a file/folder at random.
Deletes capistrano-style release directories (except that there are dashes between the YYYY-MM-DD)