Commands tagged po (2)

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

print all except first collumn

find and grep Word docs
Find Word docs by filename in the current directory, convert each of them to plain text using antiword (taking care of spaces in filenames), then grep for a search term in the particular file. (Of course, it's better to save your data as plain text to make for easier grepping, but that's not always possible.) Requires antiword. Or you can modify it to use catdoc instead.

Generate pretty secure random passwords
These are my favourite switches on pwgen: -B Don't include ambiguous characters in the password -n Include at least one number in the password -y Include at least one special symbol in the password -c Include at least one capital letter in the password It just works! Add a number to set password length, add another to set how many password to output. Example: pwgen -Bnyc 12 20 this will output 20 password of 12 chars length.

Resolution of a image
You can use the -format switch to get the size of the image. Replace "logo:" with your image.

Find out what the day ends in
Several people have submitted commands to do this, but I think this is the simplest solution. It also happens to be the most portable one: It should work with any sh or csh derived shell under any UNIX-like OS. Oh by the way, with my German locale ($LC_TIME set appropriately) it prints "g" most of the time, and sometimes (on Wednesdays) it prints "h". It never prints "y".

Down for everyone or just me?
Check if a site is down with

Schedule a script or command in x num hours, silently run in the background even if logged out
doesn't require "at", change the "2h" to whatever you want... (deafult unit for sleep is seconds)

Send keypresses to an X application
This is a (last resort) way to automate applications that provide no other ways for automation, it would send 'Hello world' to the currently active window. See the manpage (and the -text and -window entries) for how to send special characters and target specific windows. An example: Using xwininfo, I get the id of my XPlanet background window: [email protected]:19:51:0:~> xwininfo xwininfo: Please select the window about which you would like information by clicking the mouse in that window. xwininfo: Window id: 0x3600001 "Xplanet 1.2.0" Absolute upper-left X: 0 (..etc..) Now I use xvkbd to tell it to close itself: xvkbd -xsendevent -window 0x3600001 -text "Q" Obviously, the best way is to put these commands in a shellscript - just make sure to include a short sleep (sleep .1 should suffice) after each xvkbd call, or some programs will become confused.

Get AWS temporary credentials ready to export based on a MFA virtual appliance
You might want to secure your AWS operations requiring to use a MFA token. But then to use API or tools, you need to pass credentials generated with a MFA token. This commands asks you for the MFA code and retrieves these credentials using AWS Cli. To print the exports, you can use: `awk '{ print "export AWS_ACCESS_KEY_ID=\"" $1 "\"\n" "export AWS_SECRET_ACCESS_KEY=\"" $2 "\"\n" "export AWS_SESSION_TOKEN=\"" $3 "\"" }'` You must adapt the command line to include: * $MFA_IDis ARN of the virtual MFA or serial number of the physical one * TTL for the credentials

Grep Recursively Through Single File Extension
Trac 0.12.2-stable

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: