Direct the invalid lines to a separate files

Yours , not my :wink:

awk, gawk, nawk,mawk are stand-alone utility not builtin shell.
What OS you run?

If works for you why not.

Warning on Forum Rules (10) :wink:

pipe delimited file with 1 million records

What software wrote this file?

:b:Hi frdndz,

Thank you all for your posts and suggestions,

Finally, with you help, i got the answer for my question.

# perl -e 'while (<> ){ print if(/^([^\|]*\|){1,149}[^|]$/ || /^([^\|]\|){151,}/); }' < a

My sincere thanks to SKMDU for showing patience in modifying code, and providing answer..

Thanks again,