Commands by naesk (3)

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

Create date based backups
This script creates date based backups of the files. It copies the files to the same place the original ones are but with an additional extension that is the timestamp of the copy on the following format: YearMonthDay-HourMinuteSecond

Find all files larger than 500M and less than 1GB

Find how far nested you are in subshells

Install pip with Proxy
Installs pip packages defining a proxy

Place the NUM-th argument of the most recent command on the shell
After executing a command with multiple arguments like cp ./temp/ ~/prog/ you can paste any argument of the previous command to the console, like ls -l ALT+1+. is equivalent to ls -l ./temp/ ALT+0+. stands for command itself ('ls' in this case) Simple ALT+. cycles through last arguments of previous commands.

Check if a process is running
Send signal 0 to the process. The return status ($?) can be used to determine if the process is running. 0 if it is, non-zero otherwise.

Pipe text from shell to windows cut and paste buffer using PuTTY and XMing.
Set up X forwarding in PuTTY, with X display location set to :0.0 Launch PuTTY ssh session. Launch Xming. Make sure that display is set to :0.0 (this is default). $ echo "I'm going to paste this into WINDERS XP" | xsel -i will insert the string into the windows cut and paste buffer. Thanks to Dennis Williamson at for sharing...

Find the package that installed a command

Convert seconds to [DD:][HH:]MM:SS
Converts any number of seconds into days, hours, minutes and seconds. sec2dhms() { declare -i SS="$1" D=$(( SS / 86400 )) H=$(( SS % 86400 / 3600 )) M=$(( SS % 3600 / 60 )) S=$(( SS % 60 )) [ "$D" -gt 0 ] && echo -n "${D}:" [ "$H" -gt 0 ] && printf "%02g:" "$H" printf "%02g:%02g\n" "$M" "$S" }

Make vim open in tabs by default (save to .profile)
I always add this to my .profile rc so I can do things like: "vim *.c" and the files are opened in tabs.

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: