Commands by Sizeof (2)

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

Display a block of text: multi-line grep with perl
-n reads input, line by line, in a loop sending to $_ Equivalent to while () { mycode } -e execute the following quoted string (i.e. do the following on the same line as the perl command) the elipses .. operator behaves like a range, remembering the state from line to line.

find files in a date range
Example above will recursively find files in current directory created/modified in 2010.

List all files/folders in working directory with their total size in Megabytes

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"

First pass dvd rip... The set of commands was too long, so I had to separate them into two.
This set of commands will rip a dvd title using a 2 pass mencoder xvid encode. It will provide a great quality rip. It will rip as close to 700MB as possible. (note the bitrate of -700000) Enjoy!

Run any GUI program remotely
$ ssh -X example.org xeyes The SSH server configuration requires: X11Forwarding yes # this is default in Debian And it's convenient too: Compression delayed

SSH Auto-login with password
You need to install "sshpass" for this to work. apt-get install sshpass

Insert the last argument of the previous command
for example if you did a: $ ls -la /bin/ls then $ ls !$ is equivalent to doing a $ ls /bin/ls

Mount SMB share with password containing special characters
If the password for the share your trying to mount contains special characters you can use URL escape characters. The above command uses an example as follows: username: user password: p@ss URL Encoded password: p%40ss All credit goes to Richard York: http://www.smilingsouls.net/Blog/20110526100731.html Also check out this URL Decoder/Encoder to convert your passwords. http://meyerweb.com/eric/tools/dencoder/

Find out current working directory of a process
This is an alternative to another command using two xargs. If it's a command you know there's only one of, you can just use: $ ls -l /proc/$(pgrep COMMAND)/cwd


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: