[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

Re: [K12OSN] OT: bash help - copying a series of files

Rob Owens wrote:
I've read this somewhere before, but I'm having trouble finding it on

I need to copy a series of files without using a loop.  I think the
syntax is something like:  cp /path/to/[file1 file2] /destination/folder

But that doesn't work.  Does anybody know the correct syntax?  Google
isn't so good at searching special characters like [ and {

I do this:
cp /path/to/file1 /path/to/file2 /destination/folder

If the names are as similar as you wrote though, you should be able to do this:

cp /path/to/file[12] /destination/folder

The brackets hold a list of SINGLE characters.  You can also specify ranges:

cp /path/to/file[0-9] /destination/folder
This will copy file0, file1, file2... file9 to /destination/folder.

I do this sometimes too:
cp /path/to/[Ff]ile[0-9] /destination/folder
That will ignore the case on the f in file.


Jim Thomas            Principal Applications Engineer  Bittware, Inc
jthomas bittware com  http://www.bittware.com    (603) 226-0404 x536
I'm a man.  But I can change.  If I have to.  I guess.  - Red Green

[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]