Commands using printf (206)

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

VIM: Go back to the last place you were in a document
You're perhaps editing a line, or reading a certain line of code, you use page up and down or move through the file and now you wish to return to the last position the cursor was at. '' will get you there.

How to get an absolute value
Whenever we are only interested in difference between two numbers and not the positive/negative values we can use this in script.

search google on os x
Searches Google, but requires no "", and will also search all terms input in the CL, eg: > google foo bar returns search URL "http://www.google.com/search?q=foo%20bar" You could also use awk to replace all spaces with a +, which is how the Google search handles spaces, but that makes it more than one line.

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"

Set laptop display brightness
Run as root. Path may vary depending on laptop model and video card (this was tested on an Acer laptop with ATI HD3200 video). $ cat /proc/acpi/video/VGA/LCD/brightness to discover the possible values for your display.

Combine all .mpeg files in current directory into one big one.
Good old cat & output redirection. Using this method you can combine all kinds of things - even mpeg files. My video camera makes a series of .mpeg files that are broken into 4gb chunks. Using this command I can easily join them together. Even better, combined with the cp command the files can be copied and joined in one step.

Make changes in .bashrc immediately available
Any changes to BASH shell made in .bashrc will be active in the current terminal window from the moment you execute this command, ie. aliases, prompt settings etc. No need to restart terminal. (In BASH 'source' simile to 'eval' lets you generally execute any bunch of commands stacked in a text file).

print indepth hardware info
wanna know something about your hardware? how about EVERYTHING?? then this should do ya well

Process command output line by line in a while loop
This snippet allows to process the output of any bash command line by line.

Print summary of referers with X amount of occurances
This prints a summary of your referers from your logs as long as they occurred a certain number of times (in this case 500). The grep command excludes the terms, I add this in to remove results Im not interested in.


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: