Commands by thewarden (1)

What's this? 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

check open ports without netstat or lsof

Set GIT_COMMITTER_DATE = GIT_AUTHOR_DATE for all the git commits

create a progress bar...
A simple way yo do a progress bar like wget.

Edit video by cutting the part you like without transcoding.
Examples: The following will take frames starting at 15.2 seconds for a total of 45.9 seconds: $ mencoder -ss 15.2 -endpos 30.7 -oac copy -ovc copy mymovie.avi -o myeditedmovie.avi Keep in mind -endpos is the total time, i.e. the output video in this is 3 minutes 3 seconds in length: $ mencoder -ss 1 minute -endpos 2 minutes 3 seconds -oac copy -ovc copy mymovie.avi -o myeditedmovie.avi

subtraction between lines

Tricky implementation of two-dimensional array in Bash.
Since Bash doesn't support two-dimensional arrays, you can limit your columns length by some big enough constant value ( in this example 100 ) and then index the array with i and j, or maybe write your own get() and set() methods to index the array properly like I implemented for example ( see Sample output ). For example for i=0 and j=0...99 you'll pick up one of 100 elements in the range [0,99] in the one-dimensional array. For i=1 and j=0...99 you'll pick up one of 100 elements in the range [100,199]. And so on. Be careful when using this, and remember that in fact you are always using one-dimensional array.

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

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"

execute command on all files of certain types excluding folders that match pattern

Pick a random image from a directory (and subdirectories) every thirty minutes and set it as xfce4 wallpaper
Change your wallpaper every thirty minutes (or however long you like, I suppose) to a randomly selected image in a directory and subdirectories. Bear in mind this is not safe to use if anyone else has write access to your image directory.

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.


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: