I’m trying to clean up some directories that are all named in sequence 1001, 1002, 1003 and I can’t seem to get this script to work to delete directories with a value less than a number
Contents of the DIR
1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014
My command
for i in `ls`; do if (( $i < 1011 )) then echo rm $i -rf; done
but I get the error
-su: syntax error near unexpected token `then'
Can anyone point me in the right direction?
does the job.
Note: this really removes the files and does not just print the remove commands.