What's this?

commandlinefu.com is the place to record those command-line gems that you return to again and again.

Delete that bloated snippets file you've been using and share your personal repository with the world. 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.

Get involved!

You can sign-in using OpenID credentials, or register a traditional username and password.

First-time OpenID users will be automatically assigned a username which can be changed after signing in.

Universal configuration monitoring and system of record for IT.

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:



May 19, 2015 - A Look At The New Commandlinefu
I've put together a short writeup on what kind of newness you can expect from the next iteration of clfu. Check it out here.
March 2, 2015 - New Management
I'm Jon, I'll be maintaining and improving clfu. Thanks to David for building such a great resource!

Top Tags



Psst. Open beta.

Wow, didn't really expect you to read this far down. The latest iteration of the site is in open beta. It's a gentle open beta-- not in prime-time just yet. It's being hosted over at UpGuard (link) and you are more than welcome to give it a shot. Couple things:

  • » The open beta is running a copy of the database that will not carry over to the final version. Don't post anything you don't mind losing.
  • » If you wish to use your user account, you will probably need to reset your password.
Your feedback is appreciated via the form on the beta page. Thanks! -Jon & CLFU Team

Get the total length of all video / audio in the current dir (and below) in H:m:s

Terminal - Get the total length of all video / audio in the current dir (and below) in H:m:s
find -type f -name "*.avi" -print0 | xargs -0 mplayer -vo dummy -ao dummy -identify 2>/dev/null | perl -nle '/ID_LENGTH=([0-9\.]+)/ && ($t +=$1) && printf "%02d:%02d:%02d\n",$t/3600,$t/60%60,$t%60' | tail -n 1
2009-09-24 15:50:39
User: syssyphus
Functions: find perl printf tail xargs
Get the total length of all video / audio in the current dir (and below) in H:m:s

change the *.avi to whatever you want to match, you can remove it altogether if you want to check all files.


There are 8 alternatives - vote for the best!

Terminal - Alternatives
mplayer -vo dummy -ao dummy -identify * 2>&1 | grep ID_LENGTH | sed 's/.*=\([0-9]*\)/\1/' | xargs echo | sed 's/ /+/g' | bc | awk 'S=$1; {printf "%dh:%dm:%ds\n",S/(60*60),S%(60*60)/60,S%60}'
2009-09-24 10:33:19
User: Strawp
Functions: awk bc echo grep sed xargs

You're behind on your TV catch-up, but how far behind? This command tries to open mplayer against all files in the current dir. If it's a video file it will contain ID_LENGTH, which is summed and output in hours, minutes and seconds.

Someone better at awk could probably reduce this down a lot.

mplayer -endpos 0.1 -vo null -ao null -identify *.avi 2>&1 |grep ID_LENGTH |cut -d = -f 2|awk '{SUM += $1} END { printf "%d:%d:%d\n",SUM/3600,SUM%3600/60,SUM%60}'
2011-12-12 15:49:07
User: Coderjoe
Functions: awk cut grep printf

Better awk example, using only mplayer, grep, cut, and awk.

find -type f -iregex '.*\.\(mkv\|mp4\|wmv\|flv\|webm\|mov\|dat\|flv\)' -print0 | xargs -0 mplayer -vo dummy -ao dummy -identify 2>/dev/null | perl -nle '/ID_LENGTH=([0-9\.]+)/ && ($t +=$1) && printf "%02d:%02d:%02d\n",$t/3600,$t/60%60,$t%60' | tail -n 1
2014-06-07 15:50:41
User: powerinside
Functions: find perl printf tail xargs

Use case insensitive regex to match files ending in popular video format extensions and calculate their total time. (traverses all files recursively starting from the current directory)

Know a better way?

If you can do better, submit your command here.

What others think

Is there a good way to do this with audio? Gonna be working on that myself...

Comment by linuxrawkstar 381 weeks and 5 days ago

same command will work with anything mplayer will read, video or audio (just change the find options):

find -type f -name "*.mp3" -print0 | xargs -0 mplayer -vo dummy -ao dummy -identify 2>/dev/null | perl -nle '/ID_LENGTH=([0-9\.]+)/ && ($t +=$1) && printf "%02d:%02d:%02d\n",$t/3600,$t/60%60,$t%60' | tail -n 1

Comment by syssyphus 381 weeks and 5 days ago

you can remove the last part "|tail -n 1" and it will kinda give you an indication of progress.

Comment by syssyphus 381 weeks and 5 days ago

@syssyphus :D weeeeeeeeee!

Comment by linuxrawkstar 381 weeks and 5 days ago

Cotton Bags as well as Jute Bag will be the only remedy along with gumption to support the main cause of environment-friendly bags as an alternative to those crafted from plastic which is a risk on the environment. Obtaining these kinds of bags crafted from natural fibers might be relied as the modest endeavor with adding and taking a stage additionally in the direction of conserving Mother nature. You can invest in different variations and assortment accessible in this sort of Organic cotton Bags or even calm down for a Jute Bag instead. There are lots of reputed models which often concentrate on these bags. If you would like to possess a fashionable nevertheless basic bag compared to Pure cotton Bags along with Jute Bag can be your strength. There are several folks who can't live without this sort of bags and like buying from this sort of bags as it demonstrates precisely how socially responsibility that you are in the direction of ones planet. It's a environment friendly option of which will save and also stops the natural environment via getting additionally toxified from your harm performed to the environment through all those non-recyclable plastic material bags. Pure cotton bags as well as Jute Bag on the other hand tend to be totally bio-degradable and also re-usable which makes it a smaller amount safe for the setting you reside with. Acquiring such bags will surely be described as a damage-control get on your behalf. Both Cotton Bags as well as Jute Bag can be found in several floral prints, whirls and also other styles. In terms of having numerous things, Organic cotton Bags as well as Jute Bag work most effectively because they are resilient, solid, pure and also cost-effective of which will serve your goal. From month to month grocery shopping to merely using it as a fashion accessory, it gives an individual of which neat, chic and chic seem easily. These bags can also be quickly machine washable which makes it user-friendly still cost-effective and a stylish choice. Again in case you are thinking of a great way to advertise your companys manufacturer along with logo design after that giving Cotton Bags and also Jute Bag can be quite a genuinely impressive and interesting way of brand name campaign. Reward customers and also clients this sort of Organic cotton Bags along with Jute Bag as a token involving admiration. This can not only help promote your small business or maybe firm but additionally results in an incredible process to pacify them. The business emblem or even signature is available to be branded in the bag as well as can even be imprinted together with pictures of characters or interesting one-liners along with jingles to have consideration.Another important factor that you should look into while purchasing this kind of Pure cotton Bags along with Jute Bag is the sort of deal with as it can help determine whether it may sense of balance the weight of bag adequately. Choose from these Cotton Bags and Jute Bag which are utility-based and is also take to be able to straightforward. Be it a duffel bag, laundry washing bag, cash bag, handbag, baby sling bag, gunny bag, rucksack, carrier bag or even burlap each are made from such natural and organic http://www.hermesbeltsbirkinkellybag.co.uk/ fabric and also fabric making it a multi-purpose and eco-friendly option amongst purchasers. What are you actually expecting? Twenty-four hours a day help for ones environment in addition to say no to plastic-type!!

Comment by stephanieg915 16 hours ago

Your point of view

You must be signed in to comment.