I know questions regarding this error have been asked before - but I can't seem to figure out why this isn't working in this case: for aliases.
I have the following
alias scpip='scp $1 user@ip.edu:~'
I want the use case to be scpip file so that it copies the file into user's home directory in ip.edu. Instead I get the error
scp: /home/user: not a regular file
It works if I do it 'manually' ie scp file user@ip.edu:~ . How can I make this work as an alias with an argument?
$1in your alias expands to the first arg (if it exists) of the script in which you invoke it, or if used interactively (as aliases usually are) to nothing. It is followed by any arguments given in the command. Thus you are actually runningscp user@ip.edu:~ filewhich tries to copy the remote directory to a local directory confusingly namedfile, but fails. You may want a function or script instead. – dave_thompson_085 Apr 06 '22 at 02:09scpis so cumbersome it requires you to quote for the remote shell (see this answer from where it states "better don't usescpat all"). – Kamil Maciorowski Apr 06 '22 at 14:02