I have the data in my file as
START-OF-FIELDS
ID
NAME
DEPT
END-OF-FIELDS
START-OF-DATA
1|joy|cs
2|sam|ec
END-OF-DATA
START-OF-FIELDS
ID
NAME
DOB
DEPT
ADDRESS
END-OF-FIELDS
START-OF-DATA
5|joe|13/2/2001/|ee|street1
3|gwen|4/08/1999|cs|street2
END-OF-DATA
EXPECTED OUTPUT:-
ID
NAME
DEPT
Count for data set 1 is: 3
ID
NAME
DOB
DEPT
ADDRESS
Count for data set 2 is: 5 and so on for dynamic no. of data sets.
I want count of data between both START-OF-FIELDS & END-OF-FIELDS & for START-OF-DATA & END-OF-DATA. can any body give me exact code to do this. I have used
sed -n '/^START-OF-FIELDS/,/END-OF-FIELDS/{s/^START-OF-FIELDS//;/^END-OF-FIELDS/d;p;}' Sourcefile.txt > START_OF_FIELDS.TXT
wc -l START_OF_FIELDS.TXT
But I am not getting desired result.