Friday, July 6, 2012

Some Bash tips from others

I'm mostly a Windows guy. All my computers are loaded with Windows. I know how to use *nix, though not very efficiently. Since I started using Git, I have to deal with Bash more and more, through MinGW. Thus it's better to pickup some tricks of Bash to work more efficiently.


  1. !$: will be replaced with the last parameter to the last command. For example, if you just executed a command like this:
       ls /a/very/long/path
    and then you want to know the detail of what's in the path, a simple way of doing it is:
      ls -l !$
    If !$ is modified with :h, then the last part of the path is removed.
  2. ^: leading ^ will start replacing last command line with something new. Coming from last example, if part of the path is wrong, then you can try this:
        ^wrong^correct
More info can be found in this link: http://samrowe.com/wordpress/advancing-in-the-bash-shell/