Move the file from one folder to another folder

Hi,

I have a requirement to move a file from one folder(a) to another folder(b) only when folder (b) have a write permission. Folder permission is 755

If the permission is otherthan 755 we need to come out of the loop

I will appreciate your help

Thanks
Soll

Folder? Do you mean directory?

Use test:

if test -w "$directory"
then
   mv "$file" "$directory"
else
   printf "Cannot write to %s\n" "$directory" >&2
fi