
Mailing List Archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[tlug] banal bash script opinion
- Date: Sat, 17 May 2003 17:37:05 +0200
- From: Pietro Zuco <pietro@example.com>
- Subject: [tlug] banal bash script opinion
- User-agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.0.0) Gecko/20020623 Debian/1.0.0-0.woody.1
Hi.
I wanted to write a script that I pass the name of a file, the new name I want
it had and a number indicating the number of copies of that file with the new
names that I want.
Do it for me thanks ..
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
ps: don't get furious it was a joke ;-)
I wrote the script and it worked well for my needs. I just wanted to know some
suggestions about it, if it could be made in less lines.
I know this is a banal script but I'm learning bash scripting.
Thank you in advance.
I pass the name of an existing file, the new name for the copies and the numer
./scriptname filename.extension newfilename.extension number_of_copies
#!/bin/bash
x=0
extension=$(echo $1 | sed -n -e 's/[[:print:]]*\.//gp')
if [ -z $extension ]
then
while [ $x -lt $3 ]
do
cp $1 $2$x
x=`expr $x + 1`
done
else
while [ $x -lt $3 ]
do
cp $1 $2$x.$extension
x=`expr $x + 1`
done
fi
Home |
Main Index |
Thread Index