Commands by drewbled (1)

  • Does a ping scan on the local subnet and returns the IPs that are up Show Sample Output

    nmap -T4 -sn
    drewbled · 2012-06-19 17:07:24 0

What's this? 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.

Share Your Commands

Check These Out

truncate deleted files from lsof
While the posted solution works, I'm a bit uneasy about the "%d" part. This would be hyper-correct approach: $ lsof|gawk '$4~/txt/{next};/REG.*\(deleted\)$/{sub(/.$/,"",$4);printf ">/proc/%s/fd/%s\n", $2,$4}' Oh, and you gotta pipe the result to sh if you want it to actually trim the files. ;) Btw, this approach also removes false negatives (OP's command skips any deleted files with "txt" in their name).

One-liner to generate Self-Signed SSL Certificate+Key without any annoying prompts or CSRs
Handy if you want to quickly generate a self-signed certificate. Also can be used in your automated scripts for generating quick-use certificates.

Sort IP addresses
Sort IP address by order

Check every URL redirect (HTTP status codes 301/302) with curl
curl -sLkIv --stderr - -s: silences the output when piped to a different command -L: follow every redirect -k: ignores certificate errors -I: just request the headers -v: be verbose --stderr - : redirect stderr to stdout URL to check for redirects piped to grep -i location: -i: grep target text ignoring case location: : greps every string containing "location:" piped to awk {'print $3'} prints the third column in every string piped to sed '/^$/d' removes blank lines

Tail a log-file over the network
it also works with the chrome browser. The alternative with tail and nc doesn't

Print just line 4 from a textfile
Prints the 4th line and then quits. (Credit goes to flatcap in comments:

Unmount all CIFS drives

Simple top directory usage with du flips for either Linux or base Solaris
No need to type out the full OR clause if you know which OS you're on, but this is easy cut-n-paste or alias to get top ten directories by singleton. To avoid the error output from du -xSk you could always 2>/dev/null but you might miss relevant STDERR.

Sed can refference parts of the pattern in the replacement:

Find out when your billion-second anniversary is (was). (on OS X)
This is the same command as this one, but for OS X.

Stay in the loop…

Follow the Tweets.

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.


Subscribe to the feeds.

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: