Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I found this tip super helpful, for using curl to resume an interrupted file copy.

The full syntax is:

curl -C - -O file:///Volumes/path/to/file

I would like to add an alias or function called resume to my .bash_profile (on Mac) so that I can use something like

resume /Volumes/disk1/file

I was going to try something like

function resume() { ... }

but I'm not sure how to pass the argument with the file:/// prefix.

share|improve this question

1 Answer 1

Functions receive parameters just like scripts, so you can use $1 to refer to the first argument passed:

resume () {
  curl -C - -O "file://$1"
}

Note that you don't need both function and the parens; either one tells bash that it's a function.

share|improve this answer
    
That doesn't seem to work, probably because there are spaces in the path. If I do resume /Volumes/Disk\ 1/Dir\ 1/File\ 1 then curl returns curl: (37) Couldn't open file /Volumes/Disk followed by a bunch of HTML code! –  Ze'ev Sep 21 '12 at 5:18
2  
You can put quotes around the argument curl -C - -O "file://$1" –  Matteo Sep 21 '12 at 5:22

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.