Commands by jetdillo (3)

  • I came up with this because I don't have a problem remembering the big major changes I made deep inside my tree for a specific feature or bugfix but always manage to forget the trivial stuff I tweaked or touched along the way that needs to get pushed as well. Show Sample Output

    git status|awk '/modified:/ { printf("git add %s\n",$3) }; NF ==2 { printf("git add %s\n",$2) }'|sh
    jetdillo · 2012-09-03 00:09:04 1
  • Okay, commands like this are a bit of a personal peeve. awk(1) operates on a /pattern/ {action} paradigm and yet I see people leave out the /pattern/ portion of an awk command all the time, opting to use grep or sed instead. You'll save yourself some typing and time if you include the /pattern/ with your {action}.

    ps wwwwuax|awk '/command/ { printf("kill -9 %s\n",$2) }'|/bin/sh
    jetdillo · 2012-08-14 21:44:38 1
  • Use this the next time you need to come up with a reasonably random bitstring, like for a WPA/WPA2 PSK or something. Takes a continuous stream of bytes coming from /dev/urandom, runs it through od(1), picking a random field ($0 and $1 excluded) from a random line and then prints it. Show Sample Output

    cat /dev/urandom|od -t x1|awk 'NR > line { pos=int(rand()*15)+2;printf("%s",$pos);line=NR+(rand()*1000);digits = digits+2 } digits == 64 { print("\n");exit }'
    jetdillo · 2012-08-14 19:02:00 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

Convert a single-page PDF to a hi-res PNG, at 300dpi
If you skip this part: $ -density 300x300 you'll get a very lo-res image.

Find files of two different extensions and copy them to a directory

Listing today’s files only

Determining the excat memory usages by certain PID
this command gives you the total number of memory usuage and open files by the perticuler PID.

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

Create a directory and go inside it
$_ expands to the last argument of the last command that was executed

list block devices
Shows all block devices in a tree with descruptions of what they are.

How to copy CD/DVD into hard disk (.iso)
A dear friend of mine asked me how do I copy a DVD to your hard drive? If you want to make a copy of the ISO image that was burned to a CD or DVD, insert that medium into your CD/DVD drive and (assuming /dev/cdrom is associated with your computer?s CD drive) type the following command

Watch the progress of 'dd'
run this in another terminal, were xxxx is the process ID of the running dd process. the progress will report on the original terminal that you ran dd on

Shows space used by each directory of the root filesystem excluding mountpoints/external filesystems (and sort the output)
Excludes other mountpoints with acavagni's "mountpoint" idea, but with -exec instead of piping to an xargs subshell. Then, calling "du" only once with -exec's "+" option. The first "\! -exec" acts as a test so only those who match are passed to the second "-exec" for du.

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: