I have a file with some lines starting with >
I want to count the number of such lines per file.
awk '{if(/>/){count += 1}{print count}}' file.text
1
1
2
2
Obviously here I just want the last "2". Basically I want awk to print the last value of count. It seems to me that should be easy to accomplish but can't find how.
I know there are solutions such as grep -c that would do the job but I am curious to have the awk version.
Thank you
EDIT: I have tried this
awk '{if(/>/){count += 1}END{print count}}' Scaffold_1_8558356-8558657.fa_transcripts.combined.filtered.fas
awk: cmd. line:1: {if(/>/){count += 1}END{print count}}
awk: cmd. line:1: ^ syntax error