Commands by connorsy (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

Skype conversation logs to IRC-format logs

Rename all files in lower case

Rip audio from a video file.
Replace and accordingly.

The Hidden PS
While going through the source code for the well known ps command, I read about some interesting things.. Namely, that there are a bunch of different fields that ps can try and enumerate for you. These are fields I was not able to find in the man pages, documentation, only in the source. Here is a longer function that goes through each of the formats recognized by the ps on your machine, executes it, and then prompts you whether you would like to add it or not. Adding it simply adds it to an array that is then printed when you ctrl-c or at the end of the function run. This lets you save your favorite ones and then see the command to put in your .bash_profile like mine at : Note that I had to do the exec method below in order to pause with read. t () { local r l a P f=/tmp/ps c='command ps wwo pid:6,user:8,vsize:8,comm:20' IFS=' '; trap 'exec 66

File rotation without rename command
Rotates log files with "gz"-extension in a directory for 7 days and enumerates the number in file name. i.e.: logfile.1.gz > logfile.2.gz I needed this line due to the limitations on AIX Unix systems which do not ship with the rename command.

Resume an emerge, and keep all object files that are already built
For Gentoo: If you do not use this command, portage will fetch the source again, and rebuild the hole application from the top. This command make portage keep all files that ar allready built

Convert GoogleCL gmail contacts to cone adress book
Full Command: $ google contacts list name,name,email|perl -pne 's%^((?!N\/A)(.+?)),((?!N\/A)(.+?)),([a-z0-9\._-]+\@([a-z0-9][a-z0-9-]*[a-z0-9]\.)+([a-z]+\.)?([a-z]+))%${1}:${3} %imx'|grep -oP '^((?!N\/A)(.+?)) ' | sort You'll need googlecl and python-gdata. First setup google cl via: $ google Then give your PC access $ google contacts list name,email Then do the command, save it or use this one to dump it in the cone-address.txt file in your home dir: $ google contacts list name,name,email | perl -p -n -e 's%^((?!N\/A)(.+?)),((?!N\/A)(.+?)),([a-z0-9\._-]+\@([a-z0-9][a-z0-9-]*[a-z0-9]\.)+([a-z]+\.)?([a-z]+))%${1}:${3} %imx' | grep -o -P '^((?!N\/A)(.+?)) ' | sort > ~/cone-adress.txt Then import into cone. It filters out multiple emails, and contacts with no email that have N/A. (Picasa photo persons without email for example...)

Export a directory to all clients via NFSv4, read/write.
This exports a directory to the world in read/write mode. It is useful for quick, temporary NFS exports. Consider restricting the clients to a subnet or to specific hosts for security reasons (the client can be specified before the colon). On the client: mount -t nfs4 hostname:/ /mountpoint To terminate all of the exports (after unmounting on the client): exportfs -u -a Leave out the fsid=0 option if you don't want NFSv4. This works under recent versions of Linux.

Increment the filename of png in a given directory by one

Network Proxy to dump the application level forward traffic in plain text in the console and in a file.
If you have a client that connects to a server via plain text protocol such as HTTP or FTP, with this command you can monitor the messages that the client sends to the server. Application level text stream will be dumped on the command line as well as saved in a file called proxy.txt. You have to change 8080 to the local port where you want your client to connect to. Change also to the IP address of the destination server and 80 to the port of the destination server. Then simply point your client to localhost 8080 (or whatever you changed it to). The traffic will be redirected to host on port 80 (or whatever you changed them to). Any requests from the client to the server will be dumped on the console as well as in the file "proxy.txt". Unfortunately the responses from the server will not be dumped.

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: