Team:
wc -l file.txt
will generate output, for example:
42 file.txt
with wc , which also tells you the file name. It does this if you are viewing many files at the same time and want both individual and general statistics:
pax> wc -l *.txt 973 list_of_people_i_must_kill_if_i_find_out_i_have_cancer.txt 2 major_acheivements_of_my_life.txt 975 total
You can stop wc from doing this by submitting your data to standard input, so it does not know the file name:
if [[ $(wc -l <file.txt) -ge 2 ]]
The following decryption shows this in action:
pax> wc -l qq.c 26 qq.c pax> wc -l <qq.c 26
As an aside, you'll notice that I also switched to using [[ ]] and $() .
I prefer the former because it has fewer problems due to backward compatibility (mainly with line splitting), and the latter because it is much easier to embed executable files.
paxdiablo
source share