Commands by unixmonkey8556 (1)

  • Consider using this cmd when: 1. You are planning to traverse a big directory. 2. There is a subdir you don't want find to decend to. (entirely ignore) 3. You don't want find to decend to any mounted filesystems under this dir. * The -xdev flag tells find do not go to other filesystems. * -path ./junk_dir -prune is the pattern to ignore ./junk_dir entirely. * The rest is the typical search and print. To ignore multiple subdirs, you can just iterate the pattern, e.g. find . -path ./junk1 -prune -o -path ./junk2 -prune ... If you do want to include other filesystems, then remove -xdev flag. If you want to search files, then change -type d to -type f.

    find . -xdev -path ./junk_dir -prune -o -type d -name "dir_name" -a -print
    unixmonkey8556 · 2011-01-16 10:08:10 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

Remove duplicate entries in a file without sorting.
Using awk, find duplicates in a file without sorting, which reorders the contents. awk will not reorder them, and still find and remove duplicates which you can then redirect into another file.

Detach a process from the current shell
Continue to execute the command in background even though quitting the shell.

check open ports without netstat or lsof

Which processes are listening on a specific port (e.g. port 80)
swap out "80" for your port of interest. Can use port number or named ports e.g. "http"

add repeated watermark to image

check open ports without netstat or lsof

list block devices
Shows all block devices in a tree with descruptions of what they are.

Open screen on the previous command
I often find myself wanting to open screen on whatever command I'm currently running. Unfortunately, opening a fresh screen session spawns a new bash session, which doesn't keep my history, so calling screen directly with the previous command is the only way to go.

force a rescan on a host of scsi devices (useful for adding partitions to vmware on the fly)

strip config files of comments
some configuration files, particularly those installed by default as part of a package, have tons of comment lines, to help you know what's possible to configure, and what it means. That's nice, but sometimes you just want to see what specifically what _has_ been configured. That's when I use the above snippet, which I save as a bash alias 'nocom' (for 'no comments'). Apache default config files are perfect examples of when/why this script is handy.

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: