Register
It is currently Thu Jul 31, 2014 3:25 am

HELP: insert a param in alias?


All times are UTC - 6 hours


Post new topic Reply to topic  [ 3 posts ] 
Author Message
 PostPosted: Mon Sep 20, 2010 8:05 pm   

Joined: Mon Sep 20, 2010 7:56 pm
Posts: 6
Heylo guys! learning bash and joined today! yay

i have a problem. I have to constantly SCP to a remote server and therefore want to create an alias so i dont have to type the path everytime..
but for scp command the file to transmit is between scp and the path. how can i create an alias that allows me to do this?

example: alias upload="scp ____ <ridiculously long path>"
how to use: upload <filename>

thx!


Top
 Profile  
 PostPosted: Mon Sep 20, 2010 11:24 pm   

Joined: Mon Mar 02, 2009 3:03 am
Posts: 533
aliases don't accept parameters, use a function instead (defined in ~/.bashrc) such as
Code:
upload() {
   scp ____ "$1"
}
then source ~/.bashrc, and call
upload youranyfile


Top
 Profile  
 PostPosted: Tue Sep 21, 2010 6:04 am   

Joined: Mon Sep 20, 2010 7:56 pm
Posts: 6
wow thanks alot! works great


Top
 Profile  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC - 6 hours


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  


BashScripts | Promote Your Page Too
Powered by phpBB © 2011 phpBB Group
© 2003 - 2011 USA LINUX USERS GROUP