[NBLUG/talk] Create a range of files with cp

Andru Luvisi luvisi at andru.sonoma.edu
Fri Jun 13 11:16:01 PDT 2003


On Fri, 13 Jun 2003, Mark Street wrote:
> For the life of me I can't remember how to create a range of files with cp.
>
> something like cp file1 file[3-99]
>
> anyone know the syntax on this one???

You could try something like the following:

i=3; while [ $i -lt 100 ]; do cp file1 file$i; i=`expr $i + 1`; done
...or if your shell is up to it:
i=3; while (( $i < 100 )); do cp file1 file$i; i=$(($i + 1)); done

Andru
-- 
Andru Luvisi, Programmer/Analyst

Quote Of The Moment:
  If you tell the truth you don't have to remember anything.
                  -- Mark Twain




More information about the talk mailing list