how to do this in shell

Posted by user150674 on Stack Overflow See other posts from Stack Overflow or by user150674
Published on 2010-04-23T19:42:19Z Indexed on 2010/04/23 19:53 UTC
Read the original article Hit count: 511

I have a very large file, named 'ColCheckMe', tab-delimited, that you are asked to process. You are told that each line in 'ColCheckMe' has 7 columns, and that the values in the 5th column are integers. Using shell functions indicate

how you would verify that these conditions are satisfied in 'ColCheckMe'

if In the same file, each value in column 1 is unique. How would I verify that?

Also how to write a shell function that counts the number of occurrences of the word “SpecStr” in the file 'ColCheckMe'

I tried the first part which checks for the valid number of field and checks the 5th field being integer field.

nawk ' 
     NF != 7 { 
        printf("[%d] has invalid [%d] number of fields\n", FNR, NF)
     } 
     $5 !~ /^[0-9]+$/ { 
        printf("[%d] 5th field is invalid [%s]\n", FNR, $5)

}' ColCheckMe

now i wanna verify in the same file if the value in column 1 is unique.

Also is there a way to write a shell function to count the occurrences of the world "SpecStr" in the file 'ColCheckMe'

Thanks a lot

© Stack Overflow or respective owner

Related posts about shell

Related posts about perl