Hide

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.
Hide

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:

Hide

News

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!
Hide

Top Tags

Hide

Functions

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

convert single digit to double digits

Terminal - convert single digit to double digits
rename 's/\d+/sprintf("%02d",$&)/e' -- $@
2013-02-14 18:29:18
User: Vilemirth
Functions: rename
6
convert single digit to double digits

Uses 'rename' to pad zeros in front of first existing number in each filename. The "--" is not required, but it will prevent errors on filenames which start with "-". You can change the "2d" to any number you want, equaling the total numeric output: aka, 4d = ????, 8d = ????????, etc.

I setup a handful of handy functions to this effect (because I couldn't figure out how to insert a var for the value) in the form of 'padnum?', such as:

padnum5 () {

/usr/bin/rename 's/\d+/sprintf("%05d",$&)/e' -- $@

}

Which would change a file "foo-1.txt" to "foo-00001.txt"

Alternatives

There is 1 alternative - vote for the best!

Terminal - Alternatives
for i in ?.ogg; do mv $i 0$i; done
2012-05-15 02:52:52
User: Bonster
Functions: mv
21

from

1.ogg

2.ogg

3.ogg

10.ogg

11.ogg

to

01.ogg

02.ogg

03.ogg

10.ogg

11.ogg

zmv '(?.ogg)' '0$1'
2012-05-15 18:17:09
User: bst
2

works only in zsh, requires autoload zmv

function rjust_file_nums() {for i in *.ogg; do; mv $i `ruby -e "print ARGV.first.gsub(/\d+/){|d| d.rjust($1,'0')}" $i`; done}
2012-05-19 15:41:06
User: timrand
Functions: mv
2

each number in a file name gets expanded to the number of digets provided as arg_1 of the arguments in rjust_file_nums. Put the funciton in the .bashrc file. Be sure to $ source ~/.bashrc so that the function will be accessible from bash.

function rjust_file_nums(){for i in *.ogg; do; mv $i `ruby -e "print ARGV.first.gsub(/\d+/){|d| d.rjust($1,'0')}" $i`; done }
2012-05-19 15:39:39
User: timrand
Functions: mv
1

each number in a file name gets expanded to the number of digets provided as arg_1 of the arguments in rjust_file_nums. Put the funciton in the .bashrc file. Be sure to $ source ~/.bashrc so that the function will be accessible from bash.

zeros=3; from=1; to=15; for foo in $(seq $from $to); do echo mv "front${foo}back" "front$(printf "%0${zeros}d\n" $foo)back"; done
2012-05-17 10:54:45
Functions: echo mv seq
0

This command takes a few changes to get to the file format, but once you have that, you're good to go. Set your environment variables and then change the text "front" and "back" to whatever you're files start and end with. You'll end up with some easily sort-able files.

Know a better way?

If you can do better, submit your command here.

What others think

Comment by pasiword 205 weeks and 1 day ago

Satchel handbags low cost is regarded as the common along with strenuous business in recent years. The process of handbags has been said to be the easiest way for moving into the structure marketplace. With this small business, it is simple to enter style business. Using the developing change in fashion marketplace, it has become hard to stick to a certain fashion or even tendency simply. The particular below wholesale bags are normally found in large range and fashions. It is stated to be a thing that will give you a much better foundation although it is available in developing enterprise in latest market place. Handbag wholesaler signifies you must have enormous amount of handbags. As a middleman, lo shop would require specific things on your part like dependability. It is the most essential thing and also this kind of service largely rests on consistency. If you agree to source vogue handbags, you must allow it to become certain you are supplying the obtain in because of moment. The dealer really should be able wherever http://www.hermesbeltsbirkinkellybag.co.uk/ they could have confidence in giving you. Thus, it is stated for being truly very important to accompany an organization in order that you allow you to counted upon pertaining to making deadlines on because of time period. This can be a major simple fact which satchel handbags from suppliers has got to confront. Lower than replacement as being a middleman is the fact after your supply is finished. It is simple to make all of your income. You don't need to secure the intermediary or perhaps next particular person. A new dealer will be the an individual that is effectively within this organization of influencing the form design relating to that could suit the market industry. However, it mostly functions as a automobile whereby facts could be routed from your retailer who's going to be interacting immediately using the product customer. While working to be a handbag middleman, you do not need to acheive it offline where you should watch for many weeks to get an assignment. With the introduction of move forward technology in addition to electronic types of transacting small business, it has become truly a breeze and also a lot less expensive of promoting manner handbags via on the net. You'll get the purchasers or maybe shops as a result of online services. If you want to accumulate some other information regarding satchel handbags below wholesale, you can consider the aid of internet. World-wide-web is considered is the major origin in which you can get aspect information regarding that. There are many websites are offered where you may get fine detail information regarding e-commerce.

Comment by stephanieg915 1 week ago

www.

Comment by sguerra376 6 days ago

http://www.canadagoosefemmehomme2016.fr/canada-goose-blanc_171.html

http://www.canadagoosefemmehomme2016.fr/canada-goose-camp-hoody_50.html

http://www.canadagoosefemmehomme2016.fr/doudoune-canada-goose-france_265.html

http://www.canadagoosefemmehomme2016.fr/ou-acheter-une-doudoune-canada-goose_348.html

http://www.canadagoosefemmehomme2016.fr/canada-goose-bordeaux_397.html

http://www.canadagoosefemmehomme2016.fr/livigno-canada-goose_72.html

http://www.canadagoosefemmehomme2016.fr/vente-canada-goose_194.html

http://www.canadagoosefemmehomme2016.fr/canada-goose-prix_56.html

http://www.canadagoosefemmehomme2016.fr/doudoune-canada-goose-pas-cher_192.html

http://www.canadagoosefemmehomme2016.fr/canada-goose-original_190.html

http://www.canadagoosefemmehomme2016.fr/canada-goose-chilliwack-enfant_431.html

http://www.canadagoosefemmehomme2016.fr/canada-goose-marron_208.html

http://www.canadagoosefemmehomme2016.fr/canada-canada-goose_246.html

http://www.canadagoosefemmehomme2016.fr/manteau-canada-goose-prix_332.html

http://www.canadagoosefemmehomme2016.fr/langford-canada-goose_290.html

http://www.canadagoosefemmehomme2016.fr/vetements-canada-goose_64.html

http://www.canadagoosefemmehomme2016.fr/blouson-canada-goose-homme_467.html

http://www.canadagoosefemmehomme2016.fr/parka-citadel-canada-goose_253.html

http://www.canadagoosefemmehomme2016.fr/canada-goose-canada-prix_284.html

http://www.canadagoosefemmehomme2016.fr/canada-goose-femme-prix_231.html

http://www.canadagoosefemmehomme2016.fr/canada-goose-ottawa_412.html

http://www.canadagoosefemmehomme2016.fr/solaris-parka-canada-goose_110.html

Comment by sguerra376 5 days ago

http://www.canadagoosefemmehomme2016.fr/canada-goose-prix-canada_277.html

http://www.canadagoosefemmehomme2016.fr/canada-goose-pbi-chilliwack-bomber_73.html

http://www.canadagoosefemmehomme2016.fr/canada-goose-freestyle_324.html

http://www.canadagoosefemmehomme2016.fr/taille-canada-goose_79.html

http://www.canadagoosefemmehomme2016.fr/resolute-canada-goose_116.html

http://www.canadagoosefemmehomme2016.fr/canada-goose-canada_386.html

http://www.canadagoosefemmehomme2016.fr/macmillan-canada-goose_270.html

http://www.canadagoosefemmehomme2016.fr/manteau-homme-canada-goose_82.html

http://www.canadagoosefemmehomme2016.fr/canada-goose-noir-femme_346.html

http://www.canadagoosefemmehomme2016.fr/canada-goose-pour-b��b��_146.html

http://www.canadagoosefemmehomme2016.fr/manteau-canada-goose-prix_332.html

http://www.canadagoosefemmehomme2016.fr/canada-goose-expedition-homme_207.html

http://www.canadagoosefemmehomme2016.fr/canada-goose-chilliwack_393.html

http://www.canadagoosefemmehomme2016.fr/nouvelle-collection-canada-goose_451.html

http://www.canadagoosefemmehomme2016.fr/canada-goose-paris-magasin_420.html

http://www.canadagoosefemmehomme2016.fr/kensington-canada-goose_234.html

http://www.canadagoosefemmehomme2016.fr/prix-canada-goose-new-york_215.html

http://www.canadagoosefemmehomme2016.fr/canada-goose-bomber-chilliwack_119.html

http://www.canadagoosefemmehomme2016.fr/canada-goose-chilliwack-femme_191.html

http://www.canadagoosefemmehomme2016.fr/canada-goose-luxembourg_51.html

http://www.canadagoosefemmehomme2016.fr/canada-goose-kensington_86.html

Comment by sguerra376 5 days ago

http://www.canadagoosefemmehomme2016.fr/veste-canada-goose-femme_274.html

http://www.canadagoosefemmehomme2016.fr/yukon-bomber-canada-goose_147.html

http://www.canadagoosefemmehomme2016.fr/canada-goose-200_411.html

http://www.canadagoosefemmehomme2016.fr/survetement-canada-goose_356.html

http://www.canadagoosefemmehomme2016.fr/canada-goose-parka_61.html

http://www.canadagoosefemmehomme2016.fr/point-de-vente-canada-goose_304.html

http://www.canadagoosefemmehomme2016.fr/vente-de-canada-goose_361.html

http://www.canadagoosefemmehomme2016.fr/canada-goose-montebello-parka_81.html

http://www.canadagoosefemmehomme2016.fr/canada-goose-inc_430.html

http://www.canadagoosefemmehomme2016.fr/prix-canada-goose-new-york_215.html

http://www.canadagoosefemmehomme2016.fr/canada-goose-verte_154.html

http://www.canadagoosefemmehomme2016.fr/canada-goose-suisse-prix_276.html

http://www.canadagoosefemmehomme2016.fr/ou-trouver-canada-goose_232.html

http://www.canadagoosefemmehomme2016.fr/canada-goose-destockage_165.html

http://www.canadagoosefemmehomme2016.fr/montebello-parka-canada-goose_287.html

http://www.canadagoosefemmehomme2016.fr/canada-goose-manteau_438.html

http://www.canadagoosefemmehomme2016.fr/canada-goose-the-chateau_364.html

http://www.canadagoosefemmehomme2016.fr/canada-goose-noir-homme_384.html

http://www.canadagoosefemmehomme2016.fr/canada-goose-chilliwack-bomber-pas-cher_465.html

http://www.canadagoosefemmehomme2016.fr/selkirk-canada-goose_77.html

http://www.canadagoosefemmehomme2016.fr/doudoune-canada-goose-occasion_150.html

Comment by sguerra376 5 days ago

www.canadagoosefemmehomme2016.fr/canada-goose-officiel_380.html

www.canadagoosefemmehomme2016.fr/ecusson-canada-goose_168.html

www.canadagoosefemmehomme2016.fr/parka-homme-canada-goose_84.html

www.canadagoosefemmehomme2016.fr/acheter-une-canada-goose_177.html

www.canadagoosefemmehomme2016.fr/manteau-type-canada-goose_369.html

www.canadagoosefemmehomme2016.fr/canada-goose-blanc_171.html

www.canadagoosefemmehomme2016.fr/parka-canada-goose-prix_395.html

www.canadagoosefemmehomme2016.fr/canada-goose-montpellier_353.html

www.canadagoosefemmehomme2016.fr/canada-goose-fabrication_275.html

www.canadagoosefemmehomme2016.fr/le-bon-coin-canada-goose_157.html

www.canadagoosefemmehomme2016.fr/canada-goose-femme-solde_457.html

www.canadagoosefemmehomme2016.fr/manteau-homme-canada-goose_82.html

www.canadagoosefemmehomme2016.fr/canada-goose-champs-elysees_360.html

www.canadagoosefemmehomme2016.fr/canada-goose-fourrure_377.html

www.canadagoosefemmehomme2016.fr/vrai-canada-goose-pas-cher_40.html

www.canadagoosefemmehomme2016.fr/canada-goose-victoria-pas-cher_211.html

www.canadagoosefemmehomme2016.fr/canada-goose-expedition-homme_207.html

www.canadagoosefemmehomme2016.fr/whistler-parka-canada-goose_309.html

www.canadagoosefemmehomme2016.fr/canada-goose-vs-pjs_443.html

www.canadagoosefemmehomme2016.fr/doudoune-canada-goose-site-officiel_188.html

www.canadagoosefemmehomme2016.fr/gilets-canada-goose_370.html

www.canadagoosefemmehomme2016.fr/canada-goose-en-france_127.html

www.canadagoosefemmehomme2016.fr

www.canadagoosefemmehomme2016.fr/canada-goose-fr_53.html

www.canadagoosefemmehomme2016.fr/canada-goose-chilliwack-femme_191.html

www.canadagoosefemmehomme2016.fr/canada-goose-chateau_300.html

Comment by sguerra376 5 days ago

http://www.canadagoosefemmehomme2016.fr/doudoune-canada-goose-homme_328.html

http://www.canadagoosefemmehomme2016.fr/canada-goose-jogging_460.html

http://www.canadagoosefemmehomme2016.fr/canada-goose-chilliwack-enfant_431.html

http://www.canadagoosefemmehomme2016.fr/canada-goose-site-fiable_136.html

http://www.canadagoosefemmehomme2016.fr/la-canadienne-canada-goose_294.html

http://www.canadagoosefemmehomme2016.fr/vetements-canada-goose_64.html

http://www.canadagoosefemmehomme2016.fr/magasin-canada-goose-new-york_396.html

http://www.canadagoosefemmehomme2016.fr/hommes-canadian-goose_102.html

http://www.canadagoosefemmehomme2016.fr/canada-goose-femme-solde_457.html

http://www.canadagoosefemmehomme2016.fr/canada-canada-goose_246.html

http://www.canadagoosefemmehomme2016.fr/canada-goose-kensington-parka-femme_448.html

http://www.canadagoosefemmehomme2016.fr/magasin-canada-goose-paris_39.html

http://www.canadagoosefemmehomme2016.fr/canada-goose-noir-homme_384.html

http://www.canadagoosefemmehomme2016.fr/canada-goose-payer-en-plusieurs-fois_152.html

http://www.canadagoosefemmehomme2016.fr/doudoune-femme-canada-goose-pas-cher_407.html

http://www.canadagoosefemmehomme2016.fr/canada-goose-new-york-price_202.html

http://www.canadagoosefemmehomme2016.fr/canada-goose-parka_61.html

http://www.canadagoosefemmehomme2016.fr/canada-goose-a-vendre_404.html

http://www.canadagoosefemmehomme2016.fr/canada-goose-com_213.html

http://www.canadagoosefemmehomme2016.fr/canada-goose-calgary_278.html

http://www.canadagoosefemmehomme2016.fr/canada-goose-dawson-parka_374.html

http://www.canadagoosefemmehomme2016.fr/canada-goose-chilliwack-bomber-pas-cher_465.html

http://www.canadagoosefemmehomme2016.fr/canada-goose-homme-chilliwack_233.html

http://www.canadagoosefemmehomme2016.fr/doudoune-canada-goose-rose_421.html

http://www.canadagoosefemmehomme2016.fr/canada-goose-vs-pjs_443.html

http://www.canadagoosefemmehomme2016.fr/veste-canada-goose-solde_198.html

http://www.canadagoosefemmehomme2016.fr/acheter-canada-goose_446.html

Comment by sguerra376 4 days ago

http://www.canadagoosefemmehomme2016.fr/shelburne-canada-goose_418.html

http://www.canadagoosefemmehomme2016.fr/canada-goose-taille-xs_224.html

http://www.canadagoosefemmehomme2016.fr/canada-goose-foxe_91.html

http://www.canadagoosefemmehomme2016.fr/acheter-canada-goose-montreal_351.html

http://www.canadagoosefemmehomme2016.fr/mystique-parka-canada-goose_229.html

http://www.canadagoosefemmehomme2016.fr/canada-goose-bleu-marine_235.html

http://www.canadagoosefemmehomme2016.fr/doudoune-canadian-goose_205.html

http://www.canadagoosefemmehomme2016.fr/foxe-bomber-canada-goose_392.html

http://www.canadagoosefemmehomme2016.fr/vetements-canada-goose_64.html

http://www.canadagoosefemmehomme2016.fr/manteau-goose-canada-femme_149.html

http://www.canadagoosefemmehomme2016.fr/prix-d-une-canada-goose-au-canada_175.html

http://www.canadagoosefemmehomme2016.fr/ou-acheter-canada-goose-en-france_308.html

http://www.canadagoosefemmehomme2016.fr/huron-bomber-canada-goose_335.html

http://www.canadagoosefemmehomme2016.fr/canada-goose-officiel_380.html

http://www.canadagoosefemmehomme2016.fr/survetement-canada-goose_356.html

http://www.canadagoosefemmehomme2016.fr/canada-goose-a-montreal_306.html

http://www.canadagoosefemmehomme2016.fr/canada-goose-montpellier_353.html

http://www.canadagoosefemmehomme2016.fr/canada-goose-montebello-femme_373.html

http://www.canadagoosefemmehomme2016.fr/canada-goose-le-bon-march��_461.html

http://www.canadagoosefemmehomme2016.fr/canada-goose-toronto-outlet_483.html

http://www.canadagoosefemmehomme2016.fr/canada-goose-enfant_264.html

http://www.canadagoosefemmehomme2016.fr/parka-canada-goose-expedition_381.html

http://www.canadagoosefemmehomme2016.fr/acheter-doudoune-canada-goose_258.html

Comment by sguerra376 4 days ago

Your point of view

You must be signed in to comment.