I'm trying to write a bash alias/function that takes an ftp path and runs lftp
to pget
the file.
Given a remote path, with spaces encoded as %20
like:
sftp://ftp.example.com/Some%20Folder/BigFile.mov
I have this snippet to clean up the %20
and server part of the URL:
echo $1 | sed 's/%20/ /g' | sed 's/sftp:\/\/ftp.example.com//g';
which gives me
/Some Folder/BigFile.mov
Now I need to run this through lftp
like this:
lftp sftp://ftp.example.com -u user,pass -e "pget -cn10 '/Some Folder/BigFile.mov'"
I want to create an alias with a function to this command, let's call it lget
, so I can just use the original URL:
lget "sftp://ftp.example.com/Some%20Folder/BigFile.mov"
The solution here should like something like
alias lget='function _lget(){ lftp ... };_lget'
But I get completely lost as to how to include the argument in the function, have it processed through sed
, and how to handle the nested quotation marks.
I probably need some backticks ...