I'm trying to run a shell script that counts the number of rows in each file, and if the number < 2 I need to move it to a different directory.
#!/bin/bash foreach i in (ls *.DAT) a=`wc -l $i` if $a=<2 then mv $i aux1/pelvar/var/pel/projs/ar/shells/IGUD_OUT/backup endif end
But my shell gets an error:
igud_to_backup.sh: line 8: syntax error near unexpected token `('
igud_to_backup.sh: line 8: `foreach i in (ls *.DAT)'
What is wrong with the shell script?