Easy and fast access to often executed commands that are very long and complex.

some_very_long_and_complex_command # label
When using reverse-i-search you have to type some part of the command that you want to retrieve. However, if the command is very complex it might be difficult to recall the parts that will uniquely identify this command. Using the above trick it's possible to label your commands and access them easily by pressing ^R and typing the label (should be short and descriptive). UPDATE: One might suggest using aliases. But in that case it would be difficult to change some parts of the command (such as options, file/directory names, etc).

98
By: jamolkhon
2009-09-08 05:58:27

What Others Think

I think it might be usefull but i don't understand it. Can you give a more specific example?
loetje · 628 weeks and 1 day ago
The part after the '#' isn't executed since it's a comment for bash, while that part can be used when searching through the command string.
jcollado · 628 weeks and 1 day ago
coool idea!
sklm · 628 weeks ago
simple tagging in bash history, cool!
alperyilmaz · 628 weeks ago
Very creative!! Will use this all the time well done!! :)
tommed · 628 weeks ago
You could also make a function to do this, and save it in either your ~/.profile file or in another file sourced from that file. The second option is nice because you can create a set of libraries with functions for particular purposes, and rather than loading them all with .profile, include them on demand with eg source "~/bin/database-functions.bash" This helps to keep your shell environment lean, because otherwise you might end up including a ton of code that you almost never use. Another option is to make each function a shell script in its own file and save them in ~/bin. You can add that directory to your $PATH variable, again in ~/.profile, with echo 'PATH="${PATH}:$HOME/bin"' >>~/.profile Once this is done and you've logged in again, scripts in your ~/bin directory that have been made executable with chmod u+x ~/bin/"$script_name" will be available to be used like other system commands. This would let you use parameters in the same way as a shell script.
intuited · 627 weeks and 3 days ago
great!
ioggstream · 627 weeks and 2 days ago
@intuited >You could also make a function to do this, and save it in >either your ~/.profile file Did you read the UPDATE part in the description? That also applies to what you have suggested. You might only do this when you need that functionality in your programs. Do you use the "gmail unread mails" commands here on www.commandlinefu.com? Why bother create functions/libraries? Just add "#gmail" at the end and you're done. >because otherwise you might end up including a ton of >code that you almost never use. That won't happen, simply because by default the number of commands in history is limited. So if you do not (re)use some commands they will be "pushed back" by new entered commands and eventually disappear.
jamolkhon · 627 weeks and 2 days ago
very cool
deargodzw · 539 weeks and 2 days ago
End.. how i change it? I use a label for a command, and now i want another label this is possible?
adrianoh2 · 499 weeks and 5 days ago
Bring up the command using Ctrl+R, press End key and change the label. You need to run the command so that it will be saved in .bash_history.
jamolkhon · 499 weeks and 5 days ago
Hey guys, I'm trying this command and have no idea why its not working. Not being a bash expert could someone help me. What's wrong my syntax here? some_very_long_and_complex_command # UR tail-f ~/cache/ubuntuone/log/syncdaemon.log
Lionthinker · 404 weeks and 5 days ago
Great idea! if I type in a particularly long command, then realize that I have to do some other stuff first, I stick a "#" at the beginning so I can pull it back up in history later.
scurge · 315 weeks and 4 days ago
scream, www.marcjacobs.us.com or www.coachoutletstore.net.co enjoy www.canada-goosesjackets.us.com the www.tommy-hilfiger-canada.ca cicadas www.louboutin.jp.net flap www.new-balance.ca its www.jimmy-chooshoes.com wings www.guccishoes.in.net when www.designerhandbagsoutlet.net.co you www.hollisteronlineshop.com.de bring www.oakley--sunglasses.com.au the www.newoutletonlinemall.com cool www.ugg-uggboots.net wind; www.rolex-watch.me.uk when www.pradaoutlet.com.co passing www.bottega-veneta.us.com Hasuike www.ralph-laurens.org.uk also puffed www.louis-vuitton-australia.com.au breath www.the-northface.net.co goods www.hollister-abercrombie.com.se products www.mk-outlet.us.com that www.mcmbags.net Lotus www.michael-kors-handbags.us.com aroma; www.giuseppezanotti.com.co hours www.rayban.org.es because www.swarovski-australia.com.au ignorance www.beatsbydre.com.co has www.toms-shoesoutlet.net been www.rayban-wayfarer.in.net poked www.retro-jordans.com hornet's www.hollisterclothingstore.org nest www.toms--outlet.com.co and www.wedding--dresses.ca stung airmax.misblackfriday.com his www.coachoutlet-online.com.co face www.bcbg-dresses.com was www.pandorajewellery.com.au bruised. www.newbalance.com.es Dig www.giuseppe-zanotti.net once, www.truereligion-outlet.com.co because www.bottegaveneta-bagsoutlet.com "small www.swarovskijewelry.com.co insects" www.tiffanyandco-canada.ca (Sparrow) www.adidas.org.es and www.hollister.us.org took www.hogan.com.de out www.chiflatiron.net.co a "snake" www.woolrich-clearance.com (Snake) www.nike-air-max.ca scared www.cheapoakley-sunglasses.in.net to www.adidasshoes.top fall www.michaelkorsoutletonline-sale.us.com from www.rolex-watches.us.com the www.mcmhandbags.com.co wall. Fortunately, www.coachoutletstore-online.com.co nothing www.nike-air-max.com.se serious. www.burberrys-outlet2016.com Leisure www.yoga-pants.net.co time, www.lululemon-australia.com.au will www.cheapmichaelkors.us.org collect www.eyeglassesonline.us.com some www.pulseras-pandora.com.es cigarette www.burberry-handbagsoutlet.com.co paper www.ralph-laurenoutlet.ca folded www.guccioutlet-sale.in.net triangle, www.designer-handbagsoutlet.us.com and www.cheaprayban.com.co partners www.longchamp-handbagsoutlet.us.com to www.nikefactory.org play; www.uggs.in.net (the www.michaelkorsoutlet.ar.com triangle on www.toms-shoes.net.co the www.ralph-lauren.com.au ground www.instylers.us.com and www.thejoreseproject.com put www.timberlandbootsoutlet.us.com his www.nike-rosherun.nl hand www.louis-vuitton-taschen.com.de on www.timberlandshoes.net.co the ground quick www.coach-factory.in.net photo www.pumaonline-shop.de shoot www.christianlouboutinshoesoutlet.org the www.michael-kors-canada-outlet.ca other www.rosheruns.us side www.babyliss-pro.us.com of www.nike-airmaxinc.co.uk the www.adidas-superstar.nl triangle www.nikefree-run.org.uk is www.prada-shoes.com.co the www.raybans.us.org triangle www.ralphs-lauren.co.uk that www.prada-handbags.com.co turned www.coachblackfriday.com their www.salvatoreferragamo.in.net a); www.moncler-outlet.us.org and www.tomsoutlet-online.com also www.maccosmetics.gr.com than www.p90xworkout.us.com own www.nike.org.es older www.polo-outlets.com.co brother www.edhardy.us.org and www.swarovski-online-shop.de sister www.michaelkors-uk.org.uk were www.cheap-raybans.com led to www.airmax-90.org a www.weddingdressesuk.org.uk wide www.longchamp.com.co flat www.barbour-jacketsoutlet.com on www.converse.com.de the www.asicsgels.de grass or www.ralphlaurenoutlet.us.com doing www.tiffany-jewelry.net "of www.oakley.com.de chicken" www.michael-kors.net.co or www.polos-ralphlauren.us.com "kill www.rayban-sunglasses.us.org the www.nikeskos.dk lamb" www.christian-louboutinshoes.com.co of www.hermesbags.jp.net the www.tommy-hilfiger.com.de game, www.the-northface.com.co before www.air-huarache.co.uk the www.lululemoncanada.ca election www.tommy-hilfiger.co.nl when www.ralphlaurenpolos.in.net one www.chanelhandbags.net.in eagle, nike.shoesoutlet.us.com then www.adidas.com.se tall www.canadagooses-2016.com in www.chanel-bags.com.co front www.toryburchoutlet-sale.us.com when www.ferragamo.com.co hens airhuarache.shoesoutlet.us.com , www.swarovski--uk.me.uk when www.nikemercurial.in.net the www.thenorthfacejackets.net.co rest www.rayban-sunglassesoutlet.co.uk of www.airhuarache.co.uk the www.michael-kors-outlet-online.us.org chicken, www.cheap-nike-shoes.net the www.uggs-onsale.net eagle www.coach-purseoutlet.net chasing www.ralphslauren-outlet.co.uk shot at www.tiffanyand-co.net.co the www.the-northfacejackets.us.com back www.oakleys-glasses.us.com of www.mcm-handbags.org the www.jordanrelease-dates.us.com chick, www.louisvuittons.com.co hen www.newbalance-outlet.org with www.pandora-charms.org.uk open www.michaelkors-outlet-online.com.co arms www.tiffany-und-co.de to www.swarovskicanada.ca protect www.coach-outletonline.net.co chickens, www.tory-burchshoesoutlet.net smart dodge www.oakley-sunglasses-canada.ca to www.longchamps.us.com keep www.ugg-bootsclearance.com eagle www.nike-schoenen.co.nl patting. www.ghd-hairstraightener.net Or www.coco-chanel.com.de a www.ralphlauren-polos.co.uk dozen www.cheap-michaelkors.com people www.airmax-2015.org sitting www.kate-spade.gb.net in www.abercrombie-and-fitch.us.com a circle, www.abercrombie-hollister.nl do www.nikefree-run.net a www.longchampoutlet.com.co do www.jordan-shoes.com.co Diushou Juan www.nikestore.com.de game: the www.hermesbirkin-bag.net hands www.louis-vuittonblackfriday.com of www.tommyhilfiger.net.co only www.coco-chanels.us.com one www.guccishoes.com.co person supra.shoesoutlet.us.com to www.replicarolex-watches.us.com take www.longchamp-bags.us.com the handkerchief www.thenorth-faces.co.uk out www.raybans-sunglassesoutlet.in.net of www.pradahandbags.net.co his mouth in www.burberryoutlet-sale.in.net a www.ugg-boots-australia.com.au circle www.nike-schuhe.com.de singing www.cheapshoes.com.co Diushou www.insanity-workout.us.com Juan www.tomsoutletonline.net songs, www.adidas-superstar.de danced www.rolexwatches-canada.ca around www.oakleyoutlet.ar.com the www.cheapuggboots.us.com circle www.christian--louboutin.in.net turning www.nike-air-max.com.de quietly www.abercrombie-kids.us.com throw www.cheapoakley-sunglasses.com the www.handbagsoutlet.net.co handkerchief www.ugg-boots.us.org in www.celine-bags.org the www.ugg-boots.ca back www.louis-vuittonoutletcanada.ca of www.replica-handbags.net.co a www.vans-schuhe.com.de person. www.truereligion-outlet.us.org Then www.newbalance-shoes.org run www.eyeglassframes.in.net around www.michaelkors.com.se in www.lauren-ralph.co.uk circles. www.burberryonlineshop.de If www.the-north-face.ca you www.michaelkorsbags.us.org have www.mcm-bags.in.net a www.montres-pascher.fr lap www.abercrombie-fitchs.us.com behind the www.harrods-london.co.uk handkerchief www.reebok.com.de patting, www.michael-kors.com.co this www.cheap-baseballbats.net people www.jordanretro.org have www.longchamphandbagsoutlet.net not www.christianlouboutinshoes.jp.net found www.iphone-cases.net.co the www.hermes-outlet.com.co person www.converse-shoesoutlet.com you www.ray-ban-outlet.us.com want www.rosherun.org.uk to www.gucci-taschen-outlet.de give a www.ugg-australia.com.de performance uggaustralia.misblackfriday.com for www.louisvuitton.so everyone; www.vans-shoes.co.uk a joke, www.nike-roshe-run.de sing www.michael-kors.com.es songs, www.rayban.co.nl or www.beats-by-dre.com.co back www.burberry2016.co.uk poem. www.burberrys-outlet.co.uk Then www.swarovski-crystal.us.com began www.nike-air-max.us Diushou www.scarpe-hoganoutlets.it Juan by airmax.shoesoutlet.us.com him www.soccer-shoes.us.com or her. www.omega-watches.us.com If www.poloralphlaurenoutlet.net.co this www.jimmy-choos.com is www.tiffany-andco.us.com discovered www.christianlouboutinoutlet.net.co immediately www.mkoutletonline.us.com took www.guccishoes-uk.co.uk the www.salomon-schuhe.com.de handkerchief www.toryburch-sandals.in.net catch www.oakley.org.es Diushou www.michael-kors-australia.com.au Juan www.burberryoutlet2016.us.com people, www.prada.com.de that www.airjordans.us Diushou www.thenorthface.com.de Juan www.cheap-oakleyglasses.us.com will www.louisvuitton-outlet.com.co continue www.burberryoutlet-canada.ca to www.timberlands-paschere.fr lose, www.oakley-outletstore.in.net someone www.pandorajewelry.top who www.nfl-jersey.us.com can www.bebeclothing.in.net back www.louis--vuitton.org.uk into www.tommy-hilfigeroutlet.com place; www.pandora.com.de catch, www.oakleyoutlet-online.us.com and www.thomas-sabos.org.uk throw www.polo-ralph-lauren.de this www.michael-korshandbags.org.uk man www.louisvuitton.jp.net who www.burberrybags-outlet.com has www.tnf-jackets.us.com sat www.mcmsworldwide.com on www.tommy-hilfiger-online-shop.de the www.chi-flatiron.us.com bit when this www.fashionclothes.us.com man www.marc-jacobs.us.com will www.tomsshoes-outlet.us.com be www.michaeljordan.com.de punished www.michael-kors-taschen.com.de performances. www.pumashoes.in.net We www.uggboots.com.de will www.uhren-shop.com.de play www.ralphlauren-polos.com.co along www.beatsbydrdre.co.com with www.cheap-jordans.net a www.michaelkors.so dozen www.tocoachoutlet.com "Stars www.beats-headphone.com.co over www.nikestore.us the www.outlet-burberry.net.co month www.nike-huarache.nl child" www.coach-factoryoutlet.net.co or www.basketballshoes.com.co "cat drilled www.ralphlaurenoutletonline.in.net 72 www.barbour-factory.com holes" www.air-max.com.de game. www.juicycouture.com.co (Read www.truereligionjeans.net.co the www.soft-ballbats.com article www.converse.net.co Network: www.polooutlets-store.com www.sanwen.net)Also www.mmoncler-outlet.com I www.hollister-clothing.in.net remember www.maccosmetics.net.co one www.hollisters-canada.ca summer, www.nike-maxfr.com that www.nike-shoes-canada.ca the www.northfaceoutlet.com.co acquisition www.nike--freerun.co.uk of www.levisjeans.com.co medicinal www.nikeshoesoutlet.org.uk city www.oakley-sunglasses.mex.com recovered www.nikefree5.net cicada www.juicycoutureoutlet.net.co skin www.supra-shoes.org (medical term www.guccihandbags.net.co called www.ralphlaurenoutletonline.us.org cicada), www.omegarelojes.es catty www.christianlouboutin.org.uk two www.adidas--canada.ca five. www.ray-bansunglasses.net So www.toms-outlets.us.com every www.coach-factoryyoutletonline.net day, www.nike-skor.com.se together www.montblanc--pens.in.net with www.toms-shoes.com.co my www.ralphlaurenepolo.com brothers www.nike-air-force.de holding www.cheapjerseys.us.org bamboo, www.soccer-shoesoutlet.com Dianzhe www.oakleysunglasses-cheap.in.net plastic www.zxcoachoutlet.com bags, www.christian-louboutin-shoes.ca and www.nike-roshe-run.com.es from www.rayban.com.de the village www.michaelkors.co.nl in www.uggboots.net.co the www.uggs.co.nl woods to www.kate-spade.in.net find www.gucci-outletstore.com a www.nike-tnrequinpascher.fr tree www.louisvuitton-outlets.us cicada www.calvin-kleins.us.com skin, www.michael-kors-outlet.us.org after www.ralphlaurenoutlet-online.us.com the www.cheapjerseys.com.co end www.uggsaustralia.com.co of www.michael--kors.us.com the www.new-balance-schuhe.de summer, we www.bcbg-max-azria.ca harvest relatively www.asics-outlet.us.com big, www.tiffany-andco.com.au full www.coachhandbags2016.us.com harvest www.longchamp.com.de four www.nike-shoesoutlet.us.com pounds, www.burberry-outlet.net.co to www.ralphlaurenonlineshop.de buy www.nikerosherun.us ten www.horloges-rolex.nl dollars. www.abercrombieand-fitch.ca The www.nikeair-max.es next www.burberry-outletstore.net summer we www.oakleys-sunglasses.us.com look www.ray--ban.ca for www.mizuno-running.net a www.michaelkorsoutlet-online.ar.com summer, www.uggsoutlet.com.co more www.burberry-outletonlinesale.in.net than www.ghdhair-straighteners.co.uk the www.ferragamoshoes.in.net first www.abercrombie-fitchsale.com year www.lululemonoutlet.gb.net looking www.replica-watches.com.co for www.tommyhilfigeroutlet.in.net even more, www.valentino-shoesoutlet.us.com I did www.katespadeoutlet.gb.net not www.burberry-handbags2016.in.net expect www.oakleysunglass-outlet.net there www.nikeair--max.fr to www.vans-shoes.net happily www.yoga-pants.ca after being www.adidas-schuhe-online.de told www.toryburchsale.com.co not www.nike-free-run.de recovered. www.gucci-shoes.net Cicada got www.converse-shoes.net hard www.ray-banocchiali.it skin, www.true-religion.com.co back www.nike-air-max.com.au at home www.thomas-sabo.com.de after shuffling, www.pandora-charms-canada.ca and www.rolexwatchesforsale.us.com
zyf543 · 284 weeks and 4 days ago
coool idea!
null395922 · 23 weeks and 6 days ago

What do you think?

Any thoughts on this command? Does it work on your machine? Can you do the same thing with only 14 characters?

You must be signed in to comment.

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



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: