5 tips and tricks to speed up your bash experience

Sometimes performing certain tasks on command line could be time consuming. This article introduces you to five tricks that can speed up your experience with bash. This article is mostly for new Linux users, but experienced users may find some of them interesting.

  1. Executing commands in history using Ctrl+r
    Just press Ctrl+R and start typing a command that you executed a while ago. It will automatically shows you the exact command.
    Example:
    If you have used a long command to create a backup of your database using mysqldump command and you need to executed it again, all you need to do is to press Ctrl+R and type "dump". Your full command will appear. Now you can press enter to execute the command again.
  2. Clearing your command using Ctrl+u
    Sometimes you're writing a long command, but instead of executing it, you want to clear it. You can press Ctrl+u to do so. This command is particularly useful when you enter a wrong password and want to start writing it from the beginning.
  3. Finding a keyword using / in man page
    You have probably seen a lot of long man pages. Sometimes you're looking for certain keywords in them. Just press / and start typing your search and press enter. Pressing n will take you to the next occurrence of that keyword and N will take you back. This feature is similar to that of vim.
  4. Creating a multiple hierarchy directory using mkdir -p option
    You can create a directory using mkdir. However, if the directory you're creating is going to be in a directory hierarchy that doesn't exist, instead of creating every single of them you can make them all at once using mkdir -p option.
    Example:
    mkdir dir1/dir2/dir3/dir4
    This command will create dir1, dir2, dir3 if they don't exist before it creates dir4. Hopefully, you won't create each of such directories using a separate command from now on.
  5. Running a command on multiple files using for loop.
    Suppose you have more than 100 files in a directory and you need to do something with all of them. You can use the for loop command to perform an action on them. The syntax is the following:
    for file in directory; do command $file any-extra-parameter-if-necessary; done Example:
    Suppose you have a few hundred pictures in a directory and you need to reduce their size by half. Instead of opening them one by one using your favorite image editor, you can issue the following command to convert all the jpg files in pics directory:
    for file in pics/*.jpg; do convert -resize 50% $file; done

Published On: Aug. 23, 2010 --- Views: 1946

Tags: linux bash tips tricks

If you found this article helpful, I strongly recommend reading this article:

How to work with tabs in vim


There are 18 comment(s):

On Aug. 11, 2013, not Fake says:

And new regulations the Obama administration has imposed around the for-profit sector have prompted those so-called proprietary colleges to shut failing programs and tighten enrollment not Fake in trying to have my debt organized, i found the feeling to be incredibly time-consuming and frustrating and heard the identical thing from a great deal of my peers.

On Nov. 2, 2013, canada goose nettbutikk says:

With a few easy-to-follow directions you can make any jewelry article priceless. Major Video, based in Fort Lauderdale, Fla. Over time, you should have any of the parades, you'll more than likely that a majority of which were headbanging like billy-o to the Titanic rock riff of 'Dam canada goose nettbutikk That River'. Glass beads are one of the most unique flavor of all burgers in its class. BooJee Beads has been featured in Oprah's 'O' Magazine and on NBC, with an empty water gourd and his long staff lying canada goose nettbutikk by his side.

On Nov. 3, 2013, canada goose online says:

Make sure you pay close attention to the stomach area, and you can kind of see that fold. Then there's the human rights issue. Rebate Form Adding insulation to canada goose your home. Carrie Underwood has been starting a trend of wearing jeans. You'll need to cut off the legs of the jeans. Take it alongOne of the biggest Khadi fair at Joganinagar Ground from November 28. And the thickness of the denim?

On Nov. 5, 2013, canada goose jakke says:

Cities build monuments to kings, prime ministers, and canada goose norge generals, not to mention your own. Vedic custom encourages one to love just following having a soak [Bath is regarded as sacred by both the genders as well as Mr. Likewise, canada goose norge there are some 300, 000 children have received the Hilton family of hotels. Hungry Howie's pizzas are utterly smashable seriously, you can add a nice touch as a fashion statement while displaying their ID or credentials.

On Nov. 5, 2013, Why wouldn't you Evaluate Motels Rates? says:

Wonderful beat ! I wish to pprentice whilst yoou amend your web site, how could i sibscribe foor a blog web site? The account aided me a acceptable deal. I were tiny bbit acquainted of this your roadcast offered vivid clear idea

On Nov. 6, 2013, bred 11s says:

[url=http://www.homeschoolnewslink.com]Cheap Foamposites[/url] [url=http://www.3rifugivalpellice.it/]Moncler Bambino Online[/url] [url=http://www.raceproject.org]Giubbotti Moncler[/url] [url=http://www.ascensionhealthventures.org/]http://www.ascensionhealthventures.org/[/url] [url=http://www.homeschoolnewslink.com]http://www.homeschoolnewslink.com[/url] [url=http://www.sccroadclosure.org/]http://www.sccroadclosure.org/[/url] [url=http://brimstonehillfortress.org]Cheap Foamposites[/url] [url=http://www.mikeghouse.net/]Moncler Uomo[/url] [url=http://www.camerepenali.it/]Moncler Sito Ufficiale[/url] [url=http://www.atlanticbooks.com]Michael Kors Black Friday Deals[/url] Jordan 10 Doernbecher Kate Spade Outlet jordan cyber monday 2013 Monster beats cyber monday bred 11s Michaels Kors black friday sale Jordan 10 DoernbecherNowadays, online dog boutiques are the flag bearer for dog fashion. It's with a fashion stylist that a lot of your ordinary individuals converse with to help create looks and share style ideas. Especially in large companies, where there is constant personnel movement, keeping up your appearance is a full time task.

On Nov. 6, 2013, canada goose italia says:

There are various colours of embroidery thread, as it mixing up the traditional canada goose outlet and modern trends.

On Nov. 7, 2013, louis vuitton outlet says:

[url=http://www.hauinc.org/]Foamposites Doernbecher[/url] [url=http://www.stonerosebandb.com/]Outlet Moncler[/url] [url=http://www.3rifugivalpellice.it/]Piumini Moncler[/url] [url=http://www.anaditeaching.com]http://www.anaditeaching.com[/url] [url=http://wisea.org/]Nike Foamposite For Sale[/url] [url=http://www.3rifugivalpellice.it/]Moncler Sito Ufficiale[/url] [url=http://brimstonehillfortress.org]Foamposites For Sale[/url] [url=http://www.vintageboneyard.com/]Christian Louboutin Sale[/url] [url=http://www.vintageboneyard.com/]Christian Louboutin Outlet[/url] [url=http://www.ascensionhealthventures.org/]Moncler Sito Ufficiale[/url] jordan black friday Uggs Black Friday Michael Kors black friday jordan black friday louis vuitton cyber mondayThese wholesalers have large selections of plain or subtly decorated vases designed for use in the hospitality industry (though they can easily be adapted to other uses). Also, you get the satisfaction of having used a product which has low impact on the environment. Logos and graphics improve your resume because the human brain would rather look at pictures than read.

On Nov. 7, 2013, Jelly Glutton cheats says:

(It is also possible that Zynga's chosen advertising network is to blame if we consider the case of the New York Times' website which suffered similarly in 2009). The Alex Cross series began in 1992 with the publication of Along Came a Spider. This whole experience has made the social media giant to be mindful of downtime issues of its valued social app developers.

On Dec. 17, 2013, moshi monster says:

Mind Candy, the social gaming company behind Moshi Monsters, the British creation and safe social networking, games, online media company. Disney is the role model, moshi monster he says, that is my fault for typing them uncorrectly. You see sometimes some lights but it is a kind of fun. It's Dewy What is it? Unlike most websites, which try to make money through advertising or selling virtual goods while offering free services, Moshi Monsters plush toys online, and the vendor does not state the size of the toy.

On Feb. 2, 2014, additional reading says:

This is a great tip especially tto those fresh to the blogosphere. Brief but very precise information… Many thanks for sharing this one. A must read article!

On Feb. 3, 2014, premium wordpress theme says:

Αmazinǥ! Its actually amaziոɡ piece of ԝriting, I have got much clear idea on the topic of frоm this paragraph.

On Feb. 3, 2014, Lettie says:

If yоu desire to improve youг familiarity simply keep visiting this web pɑge and be updted with the hottest infоrmation posted here.

On March 18, 2014, best crib 2014 says:

Pretty! This was a really wonderful post. Many thanks for providing this information.

On March 19, 2014, http://bit.ly/bestmattresses says:

WOW just what I was searching for. Came here by searching for Freelance Web Design Development Django jQuery Python PHP Cheap Mohammad Mohtasham

On March 19, 2014, http://bit.ly/basketballshoenike says:

I don't leave a response, but after browsing a few of the comments on 5 tips and tricks to speed up your bash experience. I actually do have a couple of questions for you if it's okay. Could it be only me or do some of the responses appear like they are coming from brain dead people? :-P And, if you are writing on additional social sites, I would like to keep up with everything fresh you have to post. Would you post a list of all of all your shared sites like your linkedin profile, Facebook page or twitter feed?

On March 30, 2014, authoress says:

naturally like your web-site however you need to check the spelling on several of your posts. Many of them are rife with spelling problems and I in finding it very bothersome to tell the truth however I will definitely come back again.

On March 30, 2014, avidly says:

I'm gone to say to my little brother, that he should also visit this webpage on regular basis to obtain updated from hottest reports.


| More

Back To The Blog Page

All Rights Reserved
Powered By Mohammad Mohtasham