lundi 25 mai 2015

How to write elif command in shell script like elseif or else command in fortran

I am facing problem using elif command in shell script like I do in fortran.

I have the employee lists of 100 companies. I want to mask out those companies having less than 500 employees. My script is

rm -f category_1.txt category_2.txt
var=company
for j in 1..100
do n=$(wc -l < $var_$j.txt)
if [ n -ge 500 ]; then 
echo $var_$j >> category_1.txt
elif       #I know it will not work
echo $var_$j >> category_2.txt
fi
done

I know, I should write "elif [ n -lt 500 ]; then". But I want to be clear whether "elif" can be used like fortran? In case of fortran, we just write

if (n .ge. 500) then
write (1, *) company(j)
else
write (2,*) company(j)
endif

Aucun commentaire:

Enregistrer un commentaire