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

Remove everything except that file

Terminal - Remove everything except that file
ls | egrep -v "[REGULAR EXPRESSION]" | xargs rm -v
2010-04-01 02:40:40
User: Saxphile
Functions: egrep ls rm xargs
-1
Remove everything except that file

This is a slight variation of an existing submission, but uses regular expression to look for files instead. This makes it vastly more versatile, and one can easily verify the files to be kept by running ls | egrep "[REGULAR EXPRESSION]"

Alternatives

There is 1 alternative - vote for the best!

Terminal - Alternatives
rm !(*.foo|*.bar|*.baz)
2010-04-13 15:13:54
User: hutch
Functions: rm
88

Deletes all files in a folder that are NOT *.foo, *.bar or *.baz files. Edit the pattern inside the brackets as you like.

rm -f !(survivior.txt)
find . ! -name <FILENAME> -delete
2010-01-13 23:29:51
User: haplo
Functions: find
Tags: files rm
8

it will remove everything except the file names matching you can use also use wildcards

( shopt -s extglob; rm !(<PATTERN>) )
2010-01-13 16:43:15
User: sputnick
Functions: rm
Tags: files rm glob shopt
7

Remove everything except that file with shell tricks inside a subshell to avoid changes in the environment.

help shopt
rm !(file_to_keep_undeleted)
2010-12-15 13:31:06
User: strzel_a
Functions: rm
6

Go to tmp :

cd /tmp; mkdir retmp; cd retmp

Create 10 files :

for i in {1..10}; do touch test$i; done

Remove all files except test10 :

rm !(test10)

Know a better way?

If you can do better, submit your command here.

What others think

In zsh, this is easy:

rm ^filename

the caret indicates logical negation. That is my second favorite feature of zsh. The first is the ability to share history between running shell instances, and not have them clobber each other when exiting. (I'm pretty sure bash doesn't do this.)

Comment by bwoodacre 349 weeks and 2 days ago

The http://www.rolexreplicauk.co.uk affected Da Vinci Automatic is bogus of a 35.6 mm in bore case crafted either of stainless animate or of rose gold. The IWC Da Vinci Automatic watch adopts a 30130 Caliber, activated by an automativ 22-jewel movement, attainable in

http://www.channel-ferries.co.uk three versions including a atramentous punch in 18kt white gold, a white punch in 18kt gold and as able-bodied as a white punch in stainless steel. These timepieces are priced at ample rates. Anxiously invented, replica IWC watches mirror every detail of the absolute counterparts and they are around undistinguishable at the aboriginal glance. They commonly amount you alone amid. Compared with the http://www.visitdevonandcornwall.co.uk absolute one, this alarm is by all allowance a acceptable saving. As a result, it is not afraid that a lot of humans buy several models at the amount of an aboriginal one. IWC replica watches are accessible in the bazaar in ample amounts, now blow one and see your activity catechumen immediately. Funnily enough, name cast companies are in allotment to accusation for the affluence of http://www.drhaushka.co.uk archetype because they accomplish so abounding variations of their signature watches. Like yield Panerai, for example. They use just ONE basal case for all their watches in their Historical series. So replica makers can just use ONE basal desing in all of their Panerai replicas. Trick of the http://www.rolexreplicasstore.uk.com trade, or just trick!

Comment by Angelina 2 weeks and 1 day ago

http://www.pumaoutletonline.com

http://mulberryoutlet.outlet-store.co.uk

http://www.suprashoes.us.com

http://www.canada--gooseoutlet.us.com

http://www.ralphlaurenoutlet.org.uk

http://www.christianlouboutin-outlet.me.uk

http://www.north-faceoutlet.us.org

http://www.outletchristianlouboutin.us.com

http://www.ferragamoshoesoutlet.net

http://www.fitflopssale.us

http://www.pandorajewelryoutlet.us.com

http://www.michaelkorsoutlet-store.us.com

http://www.tomsshoes.in.net

http://www.pandora.eu.com

http://www.canadagoose-jackets.com.co

http://www.raybansunglassesinc.us.com

http://www.salomonshoes.us.com

http://www.hollisteruksale.co.uk

http://www.adidas-trainers.org.uk

http://www.reeboktrainers.org.uk

http://www.moncler.us.com

http://www.polooutletonline.us.com

http://www.pascherlouisvuitton.fr

http://www.longchamppas-cher.fr

http://www.oakleysunglassessoutlet.us.com

http://www.mulberryhand-bags.org.uk

http://www.burberry-outletstore.in.net

http://www.nikefreerun5.co.uk

http://www.coachoutletclearancesale.com.co

http://www.lululemonoutlet.me.uk

http://www.jordan-pascher.fr

http://www.louis-vuittonhandbag.us

http://www.adidasukstore.org.uk

http://www.michaelkorsfactoryoutletonline.in.net

http://www.jordanshoes.us.com

http://www.louisvuittonsunglasses.us.com

http://www.louisvuittonoutletclearance.us.com

http://www.canada--goosejackets.ca

http://www.tiffanyand-cooutlet.us

http://www.moncleroutletonline.us.com

http://www.pradashoes.us

http://www.cheapmlbjerseys.net

http://www.ralphlaurenpolo.us.com

http://www.uggoutletonlineclearance.us.com

http://www.uggoutlet-online.us.com

http://www.nikefree5.us

http://www.canadagoose--outlet.us.com

http://www.burberryoutletstore.in.net

http://www.converseshoes.us.com

http://www.longchamphand-bags.us.com

http://www.chromeheartsoutlet.us.com

http://www.michaelkorsoutletonlineclearance.us.org

http://www.coachhandbagsclearance.us.com

http://www.coachoutletonlineshopping.us.com

http://www.rolexwatches.in.net

http://www.hermesbirkin.org

http://www.oakleysunglasseswholesaleoutlet.us.com

http://www.lululemonoutletonline.us.com

http://www.michaelkors-outletclearance.us.org

http://www.futbol-baratas.com

http://www.omegawatches.me.uk

http://www.outletmichaelkors.co.uk

http://www.truereligionjeans.org.uk

http://www.oakley-sunglasses.nom.co

http://www.uggbootssale.org.uk

http://www.swarovskicrystal.us.com

http://www.nikeblazerpas-cher.fr

http://www.oakleysun-glasses.co.uk

http://www.louisvuittonoutletlouisvuittonhandbags.us.com

http://www.ysloutletonline.com

http://www.michaelkorsuk-outlet.org.uk

http://www.toryburch.com.co

http://www.tory-burchoutlet.us.org

http://www.bottega-venetaoutlet.net

http://www.tiffany-jewellery.org.uk

http://www.rolexwatchesforsale.in.net

http://www.christianlouboutinscheap.us

http://www.louboutinpas-cher.fr

http://www.thenorth-facejacket.us.com

http://www.hermesbelts.us

http://www.canadagooseoutletcanada.us.com

http://www.soccerjerseys.us.com

http://www.truereligionoutlet.org.uk

http://www.coachoutletonlineclearance.com.co

http://www.poloralphlaurenoutletstore.us.com

http://www.ferragamooutletstore.net

http://www.foampositeshoe.net

http://www.thenorthfacejackets.eu.com

http://www.jordan-shoes.us.com

http://www.coachoutletonline-factory.us.com

http://www.louis-vuittonneverfull.us.com

http://www.louis-vuittonhandbags.org.uk

http://www.uggboots-outlet.us.org

http://www.ferragamoshoes.org.uk

http://www.wholesale-nbajerseys.com

http://www.giuseppe-zanotti-outlet.org

http://www.coachoutletclearance.us.com

http://www.thenorth-faceoutlet.us.com

http://www.cheapfootballshirt.org.uk

http://www.mulberry-handbags.co.uk

http://www.ferragamo-shoes.us.com

http://www.louisvuittonoutletlv.us.com

http://www.nikeairforce1.fr

http://www.uggoutletonlinestore.us.com

http://www.michaelkorshandbags-outlet.us.com

http://www.tiffany-jewellery.co.uk

http://www.michaelkors-handbags.co.uk

http://www.pradaoutlet.us

http://www.louisvuittonhandbagsoutlet.org.uk

http://www.hermesoutletstore.us.com

http://www.louisvuittonoutlet-onlines.us.com

http://www.adidasnmdshoes.us.org

http://www.oakleysun-glassescheap.us.com

http://www.mulberrybags.me.uk

http://www.mcm-outlet.us.com

http://www.ugg-bootsoutlet.org.uk

http://www.todsoutlet.us.org

http://www.cheapsoccerjersey.net

http://www.nike-airmaxshoes.org.uk

http://www.oakley-sunglasseswholesale.us.com

http://www.michaelkorshandbagsclearance.us.com

http://www.lacostepoloshirts.cc

http://www.michaelkorscanada.ca

http://www.cartierwatches.us

http://www.louisvuittonoutlet-stores.us.com

http://www.rayban-sunglassesoutlet.us.com

http://www.louis--vuittonoutlet.us.com

http://www.rolex-watches.it

http://www.michael-korsoutletclearance.us.com

http://www.canada--goosejackets.us.com

http://www.edhardy.us.com

http://www.thomassabo.me.uk

http://www.adidasoutletstore.in.net

http://www.fitflop.in.net

http://www.canadagoose--jackets.us.com

http://www.cheapnf-ljerseys.us.com

http://www.canadagoose-outlet.ca

http://www.tiffanyandcojewelry.us

http://www.uggoutlet-store.in.net

http://www.coachoutletclearanceonline.us.com

http://www.airjordan4.org

http://www.coachoutletclearanceonline.com.co

http://www.snowbootsforwomen.us.com.us.com

http://www.diorsunglasses.com.co

http://www.ralphlauren-pascher.fr

http://www.rayban--sunglasses.me.uk

http://www.michaelkorshandbagsoutletclearance.us.com

http://www.replicawatchesfor-sale.us.com

http://www.rolexreplicawatches.com.co

http://www.cheap-snapbacks.us.com

http://www.truereligionjeans-canada.com

http://www.coachoutletonlinestore.com.co

http://www.north-face.us.org

http://www.hermes-outlet.us.com

http://www.beats-headphones.in.net

http://www.ferragamoshoes.com.co

http://www.nike-airmax2015.us

http://www.truereligion-jean.us.com

http://www.instylerionicstyler.com

http://www.canada-gooseoutlet.com.co

http://www.jeanstruereligion.in.net

http://www.ralphlauren-polo.org.uk

http://www.tiffanyjewelry-outlet.us.com

http://www.rayban-sunglasseswholesale.us.com

http://www.truereligion-sale.in.net

http://www.swarovski-crystal.org.uk

http://www.abercrombiefitch-hollister.es

http://www.rolexwatchesforsale.me.uk

http://www.louisvuitton-handbags.co.uk

http://www.clearancefitflopssale.com

http://www.ralph-laurenpolo.it

http://www.handbagslongchamp.us.com

http://www.canadagooseoutlet-store.com

http://www.chromehearts-outlet.us.com

http://www.coachoutletstoreclearance.us.com

http://www.raybansunglassescheap.us.com

http://www.nikeroshe-run.org.uk

http://www.beatsheadphones.org.uk

http://www.hollisterclothingstore.in.net

http://www.ralphlauren-polo.in.net

http://www.tomsshoes.me.uk

http://www.cheapjordansfreeshipping.us.com

http://www.louisvuittonreplica.us.com

http://www.ugg-bootsoutlet.me.uk

http://www.swarovskicrystals.com.co

http://www.coachoutlet-onlinestore.com.co

http://www.swarovski.in.net

http://www.uggoutletuk.org.uk

http://www.canadagooseoutletcanadagoosejackets.us.com

http://www.newbalanceshoes.in.net

http://www.ralphlaurenpoloshirts.org.uk

http://www.michaelkorsfactoryoutlet.us.com

http://www.michael-korsoutletclearance.com.co

http://www.herveleger.us.com

http://www.uggs-outlet.eu.com

http://www.chaussurelouboutin.fr

http://www.polo-ralphlauren.com.co

http://www.mont-blancpens.com.co

http://www.uggsoutlet.ca

http://www.cheapnfljerseyss.us.com

http://www.longchamphandbags.org.uk

http://www.valentinooutlet.us.com

http://www.michaelkorsoutlet-factory.us.com

http://www.michaelkorsoutlet-onlineclearance.us.com

http://www.iphone-case.org.uk

http://www.ralphlaurenpoloshirts.us.com

http://www.michaelkors-outletuk.org.uk

http://www.uggoutlet.ca

http://www.airforce1.us.com

http://www.coachoutletstore.com.co

http://www.adidasyeezyboost350.us.com

http://www.adidasnmd.me.uk

http://www.salvatore-ferragamo.in.net

http://www.outletmulberry.org.uk

http://www.guccioutletonline.us.org

http://www.cheap-jordanshoes.us.com

http://www.beatsbydrdre-headphones.us.com

http://www.versacesunglasses.com.co

http://www.swarovskicrystal.in.net

http://www.coachoutletonlinesale.us

http://www.coachoutletonlinestore.eu.com

http://www.uggssale.eu.com

http://www.nhl-jerseyswholesale.us.com

http://www.coachoutletonline-store.com.co

http://www.reebokoutletstore.us.com

http://www.canadagoose-outlet.com.co

http://www.uggs-outlet.de.com

http://www.uggbootsuk.org.uk

http://www.cheapoakleysun-glasseswholesale.us.com

http://www.mulberry-handbagsoutlet.org.uk

http://www.michaelkorsfactoryoutletclearance.us.com

http://www.hollister-clothingstore.net

http://www.truereligionjeansoutlets.us.com

http://www.swarovskicrystal.me.uk

http://www.cheap-nikeshoes.cc

http://www.louis-vuittonoutletstore.us.com

http://www.uggsoutlet.org.uk

http://www.niketnpascher.fr

http://www.nike-outletonline.com

http://www.pololacostepascher.fr

http://www.truereligionjeansoutlet.co.uk

http://www.pradasunglasses.us.com

http://www.uggbootsuk.me.uk

http://www.poloralph-lauren.org.uk

http://www.air-jordanshoes.us.com

http://www.truereligionoutlet-store.us.com

http://www.coachoutletonlineclearance.us.com

http://www.toryburchhandbags.us.com

http://www.outlet-louisvuitton.us.com

http://www.tiffanyjewellery-outlet.co.uk

http://www.ugg-outlet.me.uk

http://www.thenorthface-jacket.us.com

http://www.cheapuggs.us.org

http://www.watchescartier.us.com

http://www.nike-airmax90.org.uk

http://www.fitflopsshoes.co.uk

http://www.louis-vuittonoutletstores.us.com

http://www.michaelkorsoutlet-clearance.us.com

http://www.ghdstraighteners.org.uk

http://www.uggoutlet-store.us.com

http://www.airhuarache-nike.co.uk

http://www.cheapoakleysunglass-es.us.com

http://www.kobeshoes.us

http://www.michaelkorsoutlet-uk.me.uk

http://www.nikeoutletstores.us

http://www.poloralph-lauren.us.com

http://www.celineoutletus.com

http://www.kobe9elite.us.com

http://www.cheapoakleysunglasseswhole-sale.us.com

http://www.northface.org.uk

http://www.longchamphandbag.co.uk

http://www.toms-shoes.us.com

http://www.canada--goose.ca

http://www.ugg-slippers.com.co

http://www.celine-outlet.us.com

http://www.michaelkorshandbagsoutlet.us.org

http://www.rolexwatches-uk.org.uk

http://www.katespade.org.uk

http://www.ralphlauren-polo.com.co

http://www.coachoutletstores.com.co

http://www.lebronjames.us.com

http://www.the-northfacejacket.us.com

http://www.raybans-sunglasses.com.co

http://www.longchampoutlet.us.com

http://www.linksoflondons.co.uk

http://www.airmax90.org.uk

http://www.nfljerseyswholesale.us.com

http://www.prada-handbags.co.uk

http://www.polo-ralphlaurenoutlet.us.com

http://www.airjordan11.net

http://www.fitflopssale.in.net

http://www.tiffany-andco.org.uk

http://www.nikestore-uk.me.uk

http://www.louisvuittonhandbags-outlet.us.com

http://www.coachoutlethandbags.us.com

http://www.uggsale.co.uk

http://www.michaelkorsoutletonline-clearance.us.com

http://www.timberlandboots.name

http://www.katespadehandbags.me.uk

http://www.mbt-shoesoutlet.us.com

http://www.nba-jerseyswholesale.us.com

http://www.monclerjacketsuk.co.uk

http://www.nikeairmax90.me.uk

http://www.fitflopssale.me.uk

http://www.tiffanyandcojewelry.me.uk

http://www.michaelkorsfactoryoutlet.us.org

http://www.adidas-wings.in.net

http://www.beatsbydrdre.co.uk

http://www.hollistershirts.me.uk

http://www.marc-jacobs.us.org

http://www.coach-onlineoutlet.us.com

http://www.ferragamo.eu.com

http://www.hollisterclothing.co.uk

http://www.airmaxuk.org.uk

http://www.michaelkorsoutlet-clearance.us.org

http://www.coach-factoryoutlets.us.com

http://www.abercrombie-fitch-hollister.fr

http://www.louisvuittonoutlet-clearance.us.com

http://www.hollistercanada.com

http://www.sunglassesrayban.org.uk

http://www.longchamppliage.fr

http://www.michae-kors-outlet.ca

http://www.asicsisrael.com

http://www.christianlouboutinonline.us.com

http://www.toryburch-outletstore.in.net

http://www.coachfactoryoutletcoachoutletonline.us.com

http://www.juicycoutureoutlet.net

http://www.burberrysaleoutlet.us.com

http://www.ugg-bootsclearance.us.com

http://www.fitflopsshoes.in.net

http://www.moncler.us.org

http://www.fredperrypoloshirts.com

http://www.ralphlaurenpas-cher.fr

http://www.longchamp-solde.fr

http://www.nike-rosherun.me.uk

http://www.lululemonoutlet.in.net

http://www.cheap-ray-bansunglasses.us.com

http://www.michaelkorshandbags.in.net

http://www.coachoutletcanada.com.co

http://www.rolexwatchesoutlet.us.com

http://www.truereligionjeanssale.com

http://www.mulberryhandbagssale.co.uk

http://www.toryburchoutletsonline.in.net

http://www.airmax90.us.com

http://www.wholesaleoakley-sunglasses.us.com

http://www.tiffany-andcooutlet.us.com

http://www.tiffanyuk.me.uk

http://www.nikeoutletstore.us

http://www.canadagoose.eu.com

http://www.truereligion.org.uk

http://www.coachoutletonlinesale.com.co

http://www.canadagoose-jackets.me.uk

http://www.truereligion-jeansoutlet.us.com

http://www.long-champoutlet.us.com

http://www.michaelkorswallet.net

http://www.tiffany-andco.co.uk

http://www.longchampbag.org.uk

http://www.thenorth-face.us.org

http://www.michaelkorshandbagscheap.us.com

http://www.outletmichaelkors.org.uk

http://www.louisvuittonoutlet-online.us.org

http://www.vans-shoes.cc

http://www.michaelkorsoutletonline-store.us.com

http://www.adidas-yeezyboost.us.com

http://www.louis-vuittonhandbags.me.uk

http://www.nikeairmaxshoess.co.uk

http://www.montblancpenss.us.com

http://www.long-champoutlet.in.net

http://www.mulberrysale.co.uk

http://www.louisvuittonhandbagsoutlet.us.com

http://www.tiffanycojewelry.us.com

http://www.cheapmlbjerseys.us.com

http://www.michaelkorshandbags-clearance.us.com

http://www.coachoutletonlinecoachoutlet.us.com

http://www.thenorth-facejackets.us.com

http://www.maccosmetics.in.net

http://www.nikefree-run.me.uk

http://www.michael-korsoutletsonline.us.com

http://www.thenorthfacejacket.com.co

http://www.cheapjordan-shoes.us.com

http://www.truereligionjeanssale.in.net

http://www.uggoutlet.co.uk

http://www.ralphlauren-uk.org.uk

http://www.coachoutletclearancesale.us.com

http://www.basketballshoes.us.com

http://www.michael-korsoutletstore.us.com

http://www.lebronjamesshoes.in.net

http://www.nike-mercurial.net

http://www.cheapuggsforsale.in.net

http://www.air-huarache.org.uk

http://www.outlettruereligion.in.net

http://www.christianlouboutin-shoes.org.uk

http://www.michaelkorsoutletonlinestores.us.com

http://www.cazal.us.com

http://www.michaelkorsbags.org.uk

http://www.mizunorunningshoes.us

http://www.fitflopsoutletsale.com

http://www.niketrainers.me.uk

http://www.cheapugg-boots.us.com

http://www.saclong-champ.fr

http://www.fitflopssaleclearance.in.net

http://www.cheapreplicawatches.com.co

http://www.louis-vuittonpascher.fr

http://www.ralphlauren-outletuk.co.uk

http://www.toms.us.com

http://www.michaelkorsoutletclearancesale.us.com

http://www.cartier.us.com

http://www.toryburchoutlet-online.us.com

http://www.uggboots-outlet.me.uk

http://www.louis-vuittonlv.us.com

http://www.cartier-watches.us.com

http://www.nikerosherun.me.uk

http://www.kobebryantshoes.in.net

http://www.louisvuittonhandbagssale.us.com

http://www.cheapjordansonline.us.com

http://www.rolexoutlet.us.com

http://www.louisvuitton--handbags.us.com

http://www.bootsugg.org.uk

http://www.airjordan13s.com

http://www.cartier-outlet.us.com

2016.11.29 yangying

Comment by yangying 1 week and 4 days ago

Your point of view

You must be signed in to comment.