Hi, i am currently writing a script to delete the directory named with number.
Example:
in /usr/
i have
/usr/101
/usr/102 ...... /usr/200
This is the command i type and it works, i got the directory listed where the number is <150
So i applied it to the script, and it is not working especially at awk if else comparison, screen printed ALL number (101 -200). I am suspecting the error is in awk command there. Please help.
Example:
in /usr/
i have
/usr/101
/usr/102 ...... /usr/200
This is the command i type and it works, i got the directory listed where the number is <150
Code:
ls -l /usr/ | grep ^d | awk '{ if ( $9 < 150) print $9 }'
Code:
#!/bin/bash -xv
COPYKEEP="10"
LATEST="200"
KEEPFROM=`expr $LATEST - $COPYKEEP`
if [ $KEEPFROM -gt 0 ]
then
# Find which to delete.
ls -l /usr/ | grep ^d | awk '{ if ( $9 < $KEEPFROM ) print $9 }'
fi
Comment