Another perl
:
$ perl -MList::Util=first -Tnle '
s/^\s+|\s+$//g;
@e = split /\s+/;
print if @e == 5 || @e == 6 and !first {/\D/} @e;
' file
10 2 12 1 13
Explanation
s/^\s+|\s+$//g
trim the line.@e = split /\s+/
split the line into array@e
.We will print the line if:
- array
@e
contains 5 or 6 elements. - And None of its elements contain non-digit characters (
\D
match non-digit characters).
- array