Commands using read (340)

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 your external IP address

Grep by paragraph instead of by line.
This is a command that I find myself using all the time. It works like regular grep, but returns the paragraph containing the search pattern instead of just the line. It operates on files or standard input. $ grepp or $ | grepp

Turn white color to transparent for a series of png images
mogrify can be used like convert. The difference is that mogrify overwrites files: http://www.imagemagick.org/www/mogrify.html Of course, other source colors can be used as well.

Generate random valid mac addresses
Shorter and more straightforward. Also in perl: $ perl -e 'print join(":", map { sprintf "%0.2X",rand(256) }(1..6))."\n"'

Beep siren
Infinitely plays beeps with sinusoidally changing sound frequency. Ideal for alarm on an event.

Retrieve a random command from the commandlinefu.com API
Seeing that we get back plain text anyway we don't need lynx. Also the sed-part removes the credit line.

Filter the output of a file continously using tail and grep

ssh and attach to a screen in one line.
If you know the benefits of screen, then this might come in handy for you. Instead of ssh'ing into a machine and then running a screen command, this can all be done on one line instead. Just have the person on the machine your ssh'ing into run something like $ screen -S debug Then you would run $ ssh -t user@host screen -x debug and be attached to the same screen session.

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"

flush memcached via netcat


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: