Help on script to change permissions

Hi All

I have the following script that is supposed to change permissions of incoming files to a directory, but it does not seem to do what I want, please can you help:

mkdir -p /tmp/tmpdir

find /moneta_polled01/sgsn/ -exec ls -l {} \; |grep -v rwxrwxrwx |awk '{print $9}' > /tmp/tmpdir/filelist
cd /tmp/tmpdir
/usr/bin/split -l 1000 fileslist
for i in `ls x*`
 do
  for j in cat $i
   do
    chmod 777 /moneta_polled01/sgsn/$j
   done
 done
rm -rf /tmp/tmpdir


So what I want is for that file that arrives at

/moneta_polled01/sgsn/

directory should change to full permissions.

Please can you help

FR

that's useless use of find , cat , mkdir , for and for
Try

chmod 777 $(ls -l /moneta_polled01/sgsn/ | awk '$0 !~ /rwxrwxrwx/ && /^-/{print $9}')

That works, but when there are lots of files in there, it gives an error,

argument list too long

same can be done by while loop

ls -l /moneta_polled01/sgsn/ | awk '$0 !~ /rwxrwxrwx/ && /^-/{print $9}' | while read line
do
chmod 777 "$line"
done

Ever thought of the -perm operand to find ? You then could use xargs with -max-args to limit the number of files to what chmod can take.