Commands by andrewtayloruk (3)

  • Use the AWS CLI tools to generate a list instances, then pipe them to JQ to show only their launch time and instance id. Finally use sort to bring them out in runtime order. Find all those instances you launched months ago and have forgotten about. Show Sample Output


    2
    aws ec2 describe-instances | jq '.["Reservations"]|.[]|.Instances|.[]|.LaunchTime + " " + .InstanceId' | sort -n
    andrewtayloruk · 2014-02-03 07:59:47 19
  • A quick find command to identify all TAR files in a given path, extract a list of files contained within the tar, then search for a given string in the filelist. Returns to the user as a list of TAR files found (enclosed in []) followed by any matching files that exist in that archive. TAR can easily be swapped for JAR if required. Show Sample Output


    1
    find . -type f -name "*.tar" -printf [%f]\\n -exec tar -tf {} \; | grep -iE "[\[]|<filename>"
    andrewtayloruk · 2011-01-06 13:01:38 5
  • Just a quick and simple one to demonstrate Bash For loop. Copies 'file' to multiple ssh hosts.


    7
    for h in host1 host2 host3 host4 ; { scp file user@$h:/destination_path/ ; }
    andrewtayloruk · 2009-02-16 01:02:35 313

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

Have subversion ignore a file pattern in a directory
If you don't want to commit files to subversion, and don't want those file to show up when doing an "svn stat", this command is what you need

Generate Random Text based on Length

Erase CD RW

Mount SMB share with password containing special characters
If the password for the share your trying to mount contains special characters you can use URL escape characters. The above command uses an example as follows: username: user password: p@ss URL Encoded password: p%40ss All credit goes to Richard York: http://www.smilingsouls.net/Blog/20110526100731.html Also check out this URL Decoder/Encoder to convert your passwords. http://meyerweb.com/eric/tools/dencoder/

Live stream a remote audio device over ssh using only ffmpeg
Change parameter 'plughw:0,0' in accordance with your audio device. To learn 'plughw' option, type the command aplay -l.

monitor a tail -f command with multiple processes
when using named pipes only one reader is given the output by default. Also, most commands piped to by grep use a buffer which save output until tail -f finishes, which is not convenient. Here, using a combination of tee, sub-processes and the --line-buffered switch in grep we can workaround the problem.

Find the package that installed a command

Add all unversioned files to svn

calculate md5 sums for every file in a directory tree
an alternative

Write comments to your history.
A null operation with the name 'comment', allowing comments to be written to HISTFILE. Prepending '#' to a command will *not* write the command to the history file, although it will be available for the current session, thus '#' is not useful for keeping track of comments past the current session.


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: