Welcome to the Frontpage

bourne shell (and similar) FOR loop tip

  • Print

for i in /usr/bin/newaliases /usr/bin/mailq /usr/bin/hoststat /usr/bin/purgestat; do \
rm -f $i; \
ln -s /usr/sbin/sendmail $i; \
done

 

Above is the basic form using a given list, but if you have a directory that is too large for normal shell expansion (typically 2 to 4 k in commond length) you can do the following which side steps that limit:

 

for i in `ls -1`; do \
rm -f $i; \
done