The Saturday 13 December 2008 20:12:32 Rodolfo Medina, you wrote :
> I need the right syntax to copy file.jpg 100 times with one command so to
> get 100 files named file1.jpg, file2.jpg, ..., file100.jpg.
>
> Can anybody suggest how to achieve that?
>
> Thanks for any reply
> Rodolfo
filevar="file.jpg"
basefile=${filevar%.[^.]*}
extension=${filevar##^.*.}
for i in `seq 100`
do
cp $filevar $basefile$i.$extension
done
with file the file to copy, basefile the file without the last extension and
extension the last extension (without the dot).
In a function it would be
function hundred-copy ()
{
filevar=$1 # The file to copy a hundred time
basefile=${filevar%.[^.]*} # We delete all the end from the last dot (eg
a dot followed by any others caracters)
extension=${filevar##^.*.} # We delete all the beginning until the last
dot included (biggest prefix with any caracters followed by a dot)
do
cp $filevar $basefile$i.$extension # file become
filenumber.extension
done
}
Regards,
Thomas Preud'homme
--
Why debian : http://www.debian.org/intro/why_debian
Attachment:
signature.asc
Description: This is a digitally signed message part.