Is there a way to add parameters to a command alias?

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?

Phillip

Posted 2011-10-03T17:52:57.683

Reputation: 431

Question was closed 2011-10-04T14:40:44.113

bash's alias doesn't take parameters. You need a function for this. – slhck – 2011-10-03T17:55:49.960

1@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.440

3@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

No answers