I have a file details.csv and I need to create 5 files in same folder named as details1.csv,details2.csv,details3.csv,details4.csv,details5.csv along with contents of details.csv
Thanks in Advance.
I have a file details.csv and I need to create 5 files in same folder named as details1.csv,details2.csv,details3.csv,details4.csv,details5.csv along with contents of details.csv
Thanks in Advance.
You mean you want to create copy of details.csv 5 times? Or those 5 files already exsits and you want to append the data of details.csv to them?
I need to create a copy of details.csv with different names (details1.csv,details2.csv,details3.csv,details4.csv,details5.csv) along with the data. The data must be same in all the files but only the filenames must be different.
have you tried using
CP
command?
Right. As previous poster suggested:
cp details.csv details1.csv
cp details.csv details2.csv
cp details.csv details3.csv
cp details.csv details4.csv
cp details.csv details5.csv
Yeah Its working I thought of getting it in single command rather than executing it 5 times.
for i in {1..5}
do
cp details.csv details{$i}.csv
done
this is not creating 5 different files rather it creates one file as details{1..5}.csv
I donno where I went wrong..?
try this one !
code:
i=0
while [ $i -le 4 ]
do
i=`expr $i + 1`
cp details.csv details$i.csv
done
for i in 1 2 3 4 5
do
cp details.csv details{$i}.csv
done
regards
What you wrote would probably work with the bash shell. In AIX, though, the Korn shell (ksh) is used. -=Xray=- showed you already how a for-loop in ksh is constructed.
I hope this helps.
bakunin
Maybe that would have worked if you had started ksh93
. ksh93 supports some extra syntax that default ksh
does not support.
for something like this
though I would have done almost the same as you example:
$ for i in 1 2 3 4 5
do
cp details.csv details{$i}.csv
done