The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com




View Single Post in the UNIX and Linux Forums - Click on the Thread or Permalink to View Entire Thread -->
  #5 (permalink)  
Old 09-25-2008
rubin's Avatar
rubin rubin is offline Forum Advisor  
Registered User
  
 

Join Date: Nov 2007
Posts: 321
Quote:
Originally Posted by jolecanard View Post
...Unfortunately I had already though using a loop but I still needed as many lines to do the job...(If I had to make 1000 copies that would be definitely better, but for 5 or 6...).

In fact I wanted to make sure there was not a built-in function capable to do that!

Code:
while read file
  do
   i=12
   while [ $i -lt 17 ]
    do
      cp -p "$file" /other/dir/"${file%.*}.$i"
      i=$(($i + 1))
    done
  done < files_list
Code:
$ cat files_list
xsec.1.11
xsec.2.11
xsec.3.11
...
Set the counter i (i=12) and the limit (17) to whatever value you desire.