Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

script using awk and sed

Status
Not open for further replies.

ryanildo

Programmer
Jun 26, 2002
5
US
I am creating a script that will enter a file (XYZ) and verify that a list of files (ABC) within the file (XYZ) have a certain number of fields. Specifically, I am checking to see that the listed files have nine fields and are separated by a semi-colon ; delimiter. Here is what I have so far. I need help creating part of the script that echoes the line number of any file that isn't 9 fields long or that doesn't have a semi-colon as a delimiter. Can anyone help?

BEGIN{
FS=";"
}

{
if ( NF != 9)
{
printf("%s\n", $0)
}
else
{
printf("%s\n", "The line is complete")
}

}

Any help would be much appreciated.

Thanks
 
BEGIN{
FS=";"
}

NF != 9 {
printf("%s : %d\n", FILENAME, FNR);
} vlad
+---------------------------+
|#include<disclaimer.h> |
+---------------------------+
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top