[ACCEPTED]-Counting no. of Delimiter in a row in a File in Unix-records

Accepted answer
Score: 12

Try this:

awk -F '|'  'NF != 35 {print NR, $0} ' your_filefile

0

Score: 1

This small perl script should do it:

cat records.txt | perl -ne '$t = $_; $t =~ s/[^\|]//g; print unless length($t) == 35;'

This 2 works by removing all the characters except the 1 |, then counting what is left.

Score: 1

Greg's way with bash stuff, for the bash 1 friends out there :)

while read n; do [ `echo $n | tr -cd '|' | wc -c` != 35 ] && echo $n; done < records.txt

More Related questions