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!

Creating an if statement using awk and sed

Status
Not open for further replies.

ryanildo

Programmer
Jun 26, 2002
5
US
I need to create an if statement which states that if the 9th field of a file is blank, to print the line "the following lines are incomplete."

Currently my script looks like this:

BEGIN{
FS=";"
}
NF !=9 {
printf("%s\n", "The following line is incomplete.")
printf("%s : %d\n", FILENAME, FNR);
}



basically I want the script to be able to label a file such as this as an error.
222;333;eedie;sunday;23423;90;asdfsd;adfds.dfdaf;

As of now my script doesn't detect this as an error because it is seeing that there is nine fields, but I need it to detect that the ninth field is empty. The user would look at this file and realize that a period is separatnig the true 8th and 9th field.

Any help is GREATLY appreciated!!!!!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top