4

Parse file from 2nd line in shell script

view full story
linux-howto

http://www.unix.com – Hi, I need to parse input file from 2nd line. Input file contents are, Code: ABC123;20100913115432;2000000;NO; 04;AAA;09;DDD;601020304;AAAA;1;OPTA1;OPTA2;;; 04;BBB;09;BBB;601020304;BBBB;0;OPTB1;OPTB2;OPTB3;OPTB4;OPTB5; 04;CCC;09;DDD;601020304;CCCC;1;;;;; For each line, 1] I need to check number of fields should be 12 and check 7th field value. Code: fields=$(IFS=\;; set -- $line; echo $#)  if [ $fields -ne 12 ]; then     echo "Incorrect number of fields" else   Status=`echo $line | cut -d ";" -f 7` 2] If Status -eq 1, I need to get 2nd and 4th f (HowTos)