How to copy a file from source location and paste 5 times in destination location using while loop??
Kindly help??
How to copy a file from source location and paste 5 times in destination location using while loop??
Kindly help??
while pasting filenames in destination location..we can't past same file name you want different file name. Please post the with input data and output data.
Thanks
Didn't clear actually what you are trying to say...
Assuming you want to copy one file to 5 destinations..
Copy those destinations to one file... - Dest_Path
while read line
do
cp /Source_path/file $line
done<Dest_Path
ok fine I have 3 file in source directory named as
sample.dat
sample1.dat
sample2.dat
sample3.dat
sample4.dat
so I should copy any file from here to destination location where there are no files in destination directory.
I used the following code but it showing no such file or directory
#!/bin/ksh
file="/pathname/
dest="/pathname/
while read file
do
echo $file
cp "$file" "$dest"
done < "$file"
The closing double quotes in the two variable assignments are missing, the loop variable "file" has the same name as the variable that contains the file name. I think you are looking for a "for in loop", not a "while read loop" .
is there any way i can achieve this using while read line example
file="/path"
while read line
do
echo $line
done <"$file"
I just want to read the file 5 times in destination path
Given the threads you opened in "Homework and Coursework" i suppose this to be part of your homework assignment. This assumption is further bolstered up by your insistence on using a while-loop even when told other alternative solutions.
Homework is not allowed in these boards and i suggest you open a thread in the homework part for this.
Until proven that my assumption is wrong this thread is closed and too complete answers from others*) are moderated.
bakunin
____________
*) @pamu: this means yours