I have a bash script that contains:
for i in $(stuff);
do other-stuff; cp -r $i $p;
done
but I don’t have read permissions to a specific log dump file type, let’s call it .txt
Currently I get:
cp: cannot open `file.txt’ for reading: Permission denied
Without changing any permissions, is there an easy way to copy everything except those files?
cpdoesn’t hang when it generates that message. It just skips the file. Add in verbose (cp -vr $i $p) and you’ll see that its either busy copying other files, or alternatively something else in your script is hanging.cpdoesn’t really have a way to exclude files its recursing over. If you want that, you’ll have to switch to something more featureful, liketar(possibly withfind) orrsync.Also, you should really quote your arguments, just in case they contain spaces:
cp -r "$i" "$p"