Hello,
Is it possible to do the following:
I want to run the following: mongodb bin/mongod
in my bash_profile I have
alias = "./path/to/mongodb/$1"
Thanks everyone!
Hello,
Is it possible to do the following:
I want to run the following: mongodb bin/mongod
in my bash_profile I have
alias = "./path/to/mongodb/$1"
Thanks everyone!
what you ask is very unclear, but I guess you will have better luck with functions. aliases are not very flexible
Usually when I want to pass arguments to an alias in Bash, I use a combination of an alias and a function like this, for instance:
function __t2d {
if [ "$1x" != 'x' ]; then
date -d "@$1"
fi
}
alias t2d='__t2d'
An alias will expand to the string it represents. Anything after the alias will appear after its expansion without needing to be or able to be passed as explicit arguments (e.g. $1
).
$ alias foo='/path/to/bar'
$ foo some args
will get expanded to
$ /path/bar some args
If you want to use explicit arguments, you'll need to use a function
$ foo () { /path/to/bar "$@" fixed args; }
$ foo abc 123
will be executed as if you had done
$ /path/to/bar abc 123 fixed args