1
Possible Duplicate:
Creating an alias or function, need to be able to pass in a parameter
Is there a way to do the following:
cdproject project1
where cdproject is defined as:
alias cdproject='cd /path/to/$param'
...or do I need to make this into a bash script? If so, how do I do this?
bash
'salias
doesn't take parameters. You need a function for this. – slhck – 2011-10-03T17:55:49.9601@slhck Thanks; I'm trying to build a simple function but keep getting syntax errors when trying this: function mygo() {cd $1;} – Phillip – 2011-10-03T18:04:30.217
3Use spaces:
function mygo() { cd $1; }
. Bash cares about the whitespace here. – slhck – 2011-10-03T18:06:05.4403@slhck: Bash indeed cares about whitespace, and will sooner or later bite you if you forget to double-quote the
$1
. – user1686 – 2011-10-03T18:15:52.803@grawity Worth mentioning, yes. – slhck – 2011-10-03T18:21:09.313