I have multiple text files (.fas), which look like this:
>species1 AICGICVIAGIAIYIAAICG >species2 AICGIVVYICAGAYICAGCG
>species1 AIG >species2 GCI
I'm interested in counting the number of characters in the second line (it's the same across all the species in one file as they are aligned.
My current one liner:
for i in *.fas; do echo -n "$i," && grep -m 1 -A 1 '>' $i | tail -n 1 | wc -c; done;
This works to an extent but is counting one number higher than the actual number of characters, as it is counting the newline character. How do I fix this so it only counts the number of characters excluding newline characters?