1

In bash shell, what is the command to go to a special directory based on two input arguments?

The command I want to get executed is this:

cd /home/btfoouser/mia_YOCTO/build_4/build/tmp-eglibc/deploy/images/p99/

I want to pass build4 and p99 as my input arguments to the cd command from the command line.

For example, the command will be my_cd build_4 p99, which should get translated to

cd /home/btfoouser/mia_YOCTO/build_4/build/tmp-eglibc/deploy/images/p99/

I tried:

alias my_cd ='cd /home/btfoouser/mia_YOCTO/$1/build/tmp-eglibc/deploy/images/$2'
Benjamin W.
  • 38,596
  • 16
  • 96
  • 104
Benny John
  • 19
  • 2
  • Please follow this [URL](http://stackoverflow.com/help) it will be useful to help you to lift your content quality up – Willie Cheng Jun 17 '16 at 02:24

1 Answers1

3

Aliases don't parse arguments. Use a function:

my_cd() { cd "/home/btfoouser/mia_YOCTO/$1/build/tmp-eglibc/deploy/images/$2"; }

To make the function permanent, put it in your ~/.bashrc file.

John1024
  • 103,964
  • 12
  • 124
  • 155