[ACCEPTED]-Counting no. of Delimiter in a row in a File in Unix-records
Accepted answer
Try this:
awk -F '|' 'NF != 35 {print NR, $0} ' your_filefile
0
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.
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
Source:
stackoverflow.com
More Related questions
Cookie Warning
We use cookies to improve the performance of the site. By staying on our site, you agree to the terms of use of cookies.