Connecting Tech Pros Worldwide Help | Site Map

.profile command alias

bilibytes's Avatar
Familiar Sight
 
Join Date: Jun 2008
Location: Europe
Posts: 128
#1: Jan 31 '09
Hi,

i am using a unix system and have made a .profile file to declare custom commands.
I did this by typing in that file functions like this:

Expand|Select|Wrap|Line Numbers
  1. showAllFiles(){
  2.     defaults write com.apple.finder AppleShowAllFiles $1
  3.     killall Finder
  4. }
where $1 can be set to true or false by calling this alias like this:

~user$: showAllFiles true

but now i want to be able to create commands with multiple parameters but i don't know how to do it, i would like something like the following:

Expand|Select|Wrap|Line Numbers
  1. cpFileToHtdocs(){
  2. sudo cp -i /Users/user/Documents/Projects/applicationX/code/$1
  3. /usr/local/apache2/htdocs/applicationX/$2
  4. }
i would like to be able to specify two different parameters for that command like this:

~user$: cpFileToHtdocs /from/path /to/other/path

/from/path => $1

/to/other/path => $2


if you know how to do that, i would be very pleased to hear about it,

Thank you very much

Regards
Nepomuk's Avatar
Moderator
 
Join Date: Aug 2007
Location: Germany
Posts: 2,466
#2: Feb 1 '09

re: .profile command alias


And the way you posted here doesn't work?

I guess, me might need some more information - what shell are you using for example? (You should be able to get that information by calling echo $SHELL, if your Unix is anything like Linux - which it probably is.) From what I've read, it might well be korn, but it's better to make sure. If it is korn, this tutorial (especially Listing 15) should be helpful.

Greetings,
Nepomuk
bilibytes's Avatar
Familiar Sight
 
Join Date: Jun 2008
Location: Europe
Posts: 128
#3: Feb 1 '09

re: .profile command alias


Quote:

Originally Posted by Nepomuk View Post

And the way you posted here doesn't work?

I guess, me might need some more information - what shell are you using for example? (You should be able to get that information by calling echo $SHELL, if your Unix is anything like Linux - which it probably is.) From what I've read, it might well be korn, but it's better to make sure. If it is korn, this tutorial (especially Listing 15) should be helpful.

Greetings,
Nepomuk

Hi thanks for replying!

no, i'm using mac os x with GNU bash shell.
korn is not preinstalled on mac.

ok now that I know my shell name, i'll google to find it out

Thankyou again

regards

bilibytes
bilibytes's Avatar
Familiar Sight
 
Join Date: Jun 2008
Location: Europe
Posts: 128
#4: Feb 1 '09

re: .profile command alias


here is the answer:

http://tldp.org/LDP/abs/html/complexfunct.html
Nepomuk's Avatar
Moderator
 
Join Date: Aug 2007
Location: Germany
Posts: 2,466
#5: Feb 1 '09

re: .profile command alias


Glad that you got it working!

Greetings,
Nepomuk

EDIT: As this is a Mac OS X question and we have a Mac OS X Forum, I'll move it there, but leave a redirect in the Unix / Linux Forum.
Reply