Commands by peter4512 (7)

What's this?

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.

Share Your Commands


Check These Out

Find file containing namespace in a directory of jar files.
You could subsitute javax.servlet for any namespace you need.

Tar files matching a certain wildcard
This is a shortcut to tar up all files matching a wildcard. Tar doesn't have the --include (apparently).

Get your bash scripts to handle options (-h, --help etc) and spit out auto-formatted help or man page when asked!!
This will make your bash scripts better!! process-getopt is a wrapper around getopt(1) for bash that lets you define command line options (eg -h, --help) and descriptions through a single function call. These definitions are then used in runtime processing of command line options as well as in generating help and man pages. It also saves a little time in coding and in producing nicely formatted documentation. It is quite similar to GNU's argp in glibc for compiled languages and OptionParse for python. See: Linux Gazette article 162: http://tldp.org/LDP/LGNET/162/hepple.html, http://sourceforge.net/projects/process-getopt, http://bhepple.freeshell.org/oddmuse/wiki.cgi/process-getopt

Equivalent to ifconfig -a in HPUX
Command is properly working on HP-UX 11.31

Backup your LDAP
Simple way to backup your LDAP entries: put this line on your crontab. The -n switch identifies the dbnum you want to backup (alternatively you can use -b suffix. Check man slapcat for your personal switches)

convert ascii string to hex
You can use "decode()" in a similar manner: $ python -c 'print "68656c6c6f".decode("hex")'

Create date based backups
This script creates date based backups of the files. It copies the files to the same place the original ones are but with an additional extension that is the timestamp of the copy on the following format: YearMonthDay-HourMinuteSecond

get colorful side-by-side diffs of files in svn with vim
This will diff your local version of the file with the latest version in svn. I put this in a shell function like so: $svd() { vimdiff

Find unused IPs on a given subnet
Somewhat shorter version.

Get line number of all matches in a file


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.

» http://twitter.com/commandlinefu
» http://twitter.com/commandlinefu3
» http://twitter.com/commandlinefu10

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: