Is there an awk or sed to remove invalid rows ?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • grinder332518
    New Member
    • Jun 2009
    • 28

    Is there an awk or sed to remove invalid rows ?

    I have a file with rows with 10 columns, separated by 9 “|” (pipe) separators.

    However, every now and again, I am getting spurious rows appearing with no separators at all, or other rows appearing with fewer than the 9 separators.

    There is no way for me to prevent them from appearing from within the application,

    So, my question is, is there an awk command, or, preferably, a sed command, which anyone can provide which will strip out these non-standard rows ??

    Many thanks in advance.
  • Mariostg
    Contributor
    • Sep 2010
    • 332

    #2
    You could use the NF (number of field) variable of awk.
    Code:
    FS="|"
    if (NF == 10) {
      Do your stuff;
    } else  {
      Do something else;
    }

    Comment

    Working...