Commands using awk (1,418)

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

Get the full path of a bash script's Git repository head.
Rather than complicated and fragile paths relative to a script like "../../other", this command will retrieve the full path of the file's repository head. Safe with spaces in directory names. Works within a symlinked directory. Broken down: $cd "$(dirname "${BASH_SOURCE[0]}")" temporarily changes directories within this expansion. Double quoted "$(dirname" and ")" with unquoted ${BASH_SOURCE[0]} allows spaces in the path. $git rev-parse --show-toplevel gets the full path of the repository head of the current working directory, which was temporarily changed by the "cd".

ping a host until it responds, then play a sound, then exit
This allows for sleeping in between pings. Also, espeak needs to be installed.

Find usb device in realtime
Using this command you can track a moment when usb device was attached.

convert a latex source file (.tex) into opendocument (.odt ) format
require the tex4ht package . You can open the file with openoffice , I use it much for correct my spelling and grammar .

Sort specific lines while editing within vi
Sort lines within vi editor. In this example sort lines 33-61 and lines 4-9 asciibetically.

On screen display of a command.
This is very useful if you need to show someone some text from a distance. (Like someone standing over your shoulder...) I'd recommend aliasing it to something like: alias osd_cat="osd_cat -o 400 -s 8 -c blue -d 60 -f -*-bitstream\ vera\ sans-*-*-*--200-*-*-*-*-*-*-*" xosd is the utility that provides osd_cat.

tar and remove files which are older that 100 days
tar does not have a -mtime option as find. tar appends all the file to an existing tar file.

archive all files containing local changes (svn)
This works more reliable for me ("cut -c 8-" had one more space, so it did not work)

Poke a Webserver to see what it's powered by.
the good: Server: Apache/2.2.8 (Ubuntu) PHP/5.2.4-2ubuntu5.4 with Suhosin-Patch the bad: Server: Microsoft-IIS/6.0 and the ugly: Server: Apache/2.2.10 (Win32) mod_ssl/2.2.10 OpenSSL/0.9.8i PHP/5.2.6

Install pip with Proxy
Installs pip packages defining a proxy


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: