The function 'box' takes either one or two arguments. The first argument is a line of text to be boxed, the second argument (optional) is a character to use to draw the box. By default, the drawing character will be '='. The function 'n()' is a helper function used to draw the upper and lower lines of the box, its arguments are a length, and an character to print. (I used 'n' because 'line', 'ln' and 'l' are all commonly used) Show Sample Output
underline() will print $1, followed by a series of '=' characters the width of $1. An optional second argument can be used to replace '=' with a given character.
This function is useful for breaking lots of data emitted in a for loop into sections which are easier to parse visually. Let's say that 'xxxx' is a very common pattern occurring in a group of CSV files.
You could run
grep xxxx *.csv
This would print the name of each csv file before each matching line, but the output would be hard to parse visually.
for i in *.csv; do printf "\n"; underline $i; grep "xxxx" $i; done
Will break the output into sections separated by the name of the file, underlined.
Show Sample Output
This depends on 'stripansi' and 'urlencode' commands, which exist on my system as these aliases:
alias stripansi='perl -ple "s/\033\[(?:\d*(?:;\d+)*)*m//g;"'
alias urlencode='perl -MURI::Escape -ne "\$/=\"\"; print uri_escape \$_"'
The `open` command handles URLs on a Mac. Substitute the equivalent for your system (perhaps gnome-open).
I don't use system `mail`, so I have this aliased as `mail` and use it this way:
git show head | mail
Only works on single files, doesn't preserve permissions/timestamps/ownership. Show Sample Output
generates a picture file with the text. Some other samples in: http://www.imagemagick.org/Usage/text/ Show Sample Output
This command takes a set of images (from a render, for example), and converts them into a format conforming to the Blu-ray spec, or at least the version on the Wikipedia page.
this also generates errors (change 4 to higher number for more mistakes)
man find: If no paths are given, the current directory is used. - Can anybody tell me why so many people are typing the dot?
You should install qpdf. That way, you can have a copy without any password required.
This awk command prints a histogram of the number of times 'emergency' is the first word in a line, per day, in an irssi (IRC client) log file. Show Sample Output
This awk command prints a histogram of the number of times 'emergency' is the first word in a line, per day, in an irssi (IRC client) log file. Show Sample Output
using find's exec option instead of a for loop and using sed's -i option for inplace replacement. no need to do the file swap. Show Sample Output
Mirror every lvol in vg00 in hp-ux 11.31
lists all files that are opened by processess named $processname egrep 'w.+REG' is to filter out non file listings in lsof, awk to get the filenames, and sort | uniq to remove duplciation Show Sample Output
Use sed to edit in-place a list of files returned by find.
This is the syntax for older versions of netcat.
Sometimes you need a simple server which listens on a port and prints out received data. Example: Consider you want to know, which data is posted by a homepage to a remote script without analysing the html code! A simple way to do this is to save the page to your computer, substitude all action="address" with action="localhost:portnumber", run 'ncat -l portnumber' and open the edited page with your browser. If you then submit the form, ncat will print out the http-protocol with all the posted data.
The command show the log of a branch, stopping the output at the time of branch creation.
This use the Screemr search engine to play mp3 songs
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.
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
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: