Hi All,
I have the following script, where I am copying a list of files from one location to another location. The permissions, owners are fine. Why i am getting cp: cannot access error when i run this script. But the cp works at command prompt...
files="home/file.lst"
for file in `cat $files`
do
cp $file $HOME/copy
done
Please help. Thanks.
I should have noticed this before. Your cp command is over writing each of the previous copies! So you will end up with one file in your $HOME dir named copy. Why are you doing this? I assume its a typo. You need to change the destination file name. Also, check permissions again.
This is not the reccomended naming convention, just wanted to illustrate my point!
COUNT=0
FILES=$(cat /home/file.lst)
for file in $FILES
do
cp $file $HOME/copy_$COUNT
let COUNT +=1
done