Commands by bugmagnet (1)

  • %t are tens. %d are digits. One may have further outer loops to provide hundreds, thousands, etc. This example applies ping to the numbered machines. The pattern can be used in other ways to apply all combinations of components to a task. Show Sample Output


    0
    c:\>for %t in (0 1 2 3 4 5 6 7) do for %d in (0 1 2 3 4 5 6 7 8 9) do ping -n 1 machine-0%t%d
    bugmagnet · 2012-09-18 03:31:52 4

What's this?

commandlinefu.com 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 a mirror of a local folder, on a remote server
Create a exact mirror of the local folder "/root/files", on remote server 'remote_server' using SSH command (listening on port 22) (all files & folders on destination server/folder will be deleted)

A command line calculator in Perl
Once I wrote a command line calculator program in C, then I found this... and added to it a bit. For ease of use I normally use this in a tiny Perl program (which I call pc for 'Perl Calculator') #!/usr/bin/perl -w die "Usage: $0 MATHS\n" unless(@ARGV);for(@ARGV){s/x/*/g;s/v/sqrt /g;s/\^/**/g}; print eval(join('',@ARGV)),$/; It handles square roots, power, modulus: $ pc 1+2 (1 plus 2) 3 $ pc 3x4 (3 times 4) 12 $ pc 5^6 (5 to the power of 6) 15625 $ pc v 49 ( square root of 49 ) 7 $ pc 12/3 (12 divided by 3) 4 $ pc 19%4 (19 modulus 4) 3 (you can string maths together too) $ pc 10 x 10 x 10 1000 $ pc 10 + 10 + 10 / 2 25 $ pc 7 x v49 49

grab all of google IPv4 network blocks

Load another file in vim
You can then switch from a file to another with ^W^W

View any already in progress copy command in detail
If you spot a dubious looking cp command running you can use this command to view what is being copied and to where. 1234 is the PID of the cp command being passed to the lsof utility. 3r.*REG will display the file/directory that is being read/copied. 4w.*REG will display the destination it is being written to.

View internet connection activity in a browser
In addition to generating the current connections, it also opens then in your default browser on gnome.

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

View internet connection activity in a browser
The output of lsof is piped to txt2html which converts it to html. # Perl module HTML::TextToHTML needed

A rainbow-colored Tux gives a fortune cookie for the day. Great

Quick and dirty convert to flash
This converts any media ffmpeg handles to flash. It would actually convert anything to anything, it's based on the file extension. It doesn't do ANY quality control, sizing, etc, it just does what it thinks is best. I needed an flv for testing, and this spits one out easily.


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.

» http://twitter.com/commandlinefu
» http://twitter.com/commandlinefu3
» http://twitter.com/commandlinefu10

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: