r/commandline•
[deleted]

Parsing directories

I'm trying to write a simple script that would let me copy files from one place to another.

The problem I've run into is, I'm sure, an easy fix, but I don't have much experience in any kind of scripting so I'm turning to you guys for help.

Right now, as it stands, the first couple lines look like this:

  • echo -en "Please select the source drive:\n"; ls /Volumes
  • read source

Now it works just fine, but I'd like to be able to assign each folder that's listed a unique number that I could enter to prevent typos, instead of manually typing their names.

How would I go about accomplishing that?

And while we're at it, could someone please explain the following, I'm not even sure what to call them -- things, like I'm 5?

[[, ((, do, fi, done

Posted Mar 25, 2012, 2:02 AM UTC

517
Loading comments…