On Tue, 23 Mar 2010, Claes Lindvall wrote:

> Very often I create a directory and then I want to move to that directory.
> I would like an option that makes it possible.
> Ex.
> # mkdir -c <dir> (-c changedir)
> or a new command
> # mkcdir <dir>

    I use this functon to create a directory:

md()
{
  case $1 in
     -c) mkdir -p "$2" && cd "$2" ;;
     *)  mkdir -p "$@" ;;
  esac
}

    Giving the -c option changes to the new directory if it was
    created successfully.

-- 
   Chris F.A. Johnson, <http://cfajohnson.com>
   Author:
   Pro Bash Programming: Scripting the GNU/Linux Shell (2009, Apress)
   Shell Scripting Recipes: A Problem-Solution Approach (2005, Apress)


Reply via email to