Commands by plasticphyte (2)

  • Searches Google, but requires no "", and will also search all terms input in the CL, eg: > google foo bar returns search URL " 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.

    function google () { st="[email protected]"; open "${st}"; }
    plasticphyte · 2014-05-07 03:14:05 0
  • This gets the Nth argument in the last line of your history file. This is useful where history is being written after each command, and you want to use arguments from the previous command in the current command, such as when doing copies/moving directories etc. I wrote this after getting irritated with having to continually type in long paths/arguments. You could also use $_ if all you want is the last argument. Show Sample Output

    function garg () { tail -n 1 ${HISTFILE} | awk "{ print \$$1 }" }
    plasticphyte · 2013-09-10 04:07:46 0

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

List dot-files and dirs, but not . or ..

recursively change file name from uppercase to lowercase (or viceversa)
easier way to recursively change files to lowercase using rename instead

Replace strings in text
-e is the script function, it performs search and replace like vi, and -i is the edit the file in place.

Find usb device in realtime
Using this command you can track a moment when usb device was attached.

Function to split a string into an array

Batch convert PNG to JPEG
Convert all PNG images in directory to JPEG using ImageMagick, and delete the old PNG images.

Kill all processes that listen to ports begin with 50 (50, 50x, 50xxx,...)
Run netstat as root (via sudo) to get the ID of the process listening on the desired socket. Use awk to 1) match the entry that is the listening socket, 2) matching the exact port (bounded by leading colon and end of column), 3) remove the trailing slash and process name from the last column, and finally 4) use the system(…) command to call kill to terminate the process. Two direct commands, netstat & awk, and one forked call to kill. This does kill the specific port instead of any port that starts with 50. I consider this to be safer.

Open Sublime-text in current directory

Get simple weather info from a zip code
$ weather 97405

Install pip with Proxy
Installs pip packages defining a proxy

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: