NTS: Use of grep to count instances of a certain phrase in a file
0 @I1@ INDI
1 NAME Bob /Cox/
1 SEX M
1 FAMS @F1@
1 CHAN
2 DATE 11 FEB 2006
0 @I2@ INDI
1 NAME Joann /Para/
1 SEX F
1 FAMS @F1@
1 CHAN
2 DATE 11 FEB 2006
0 @I3@ INDI
1 NAME Bobby Jo /Cox/
1 SEX M
1 FAMC @F1@
1 CHAN
2 DATE 11 FEB 2006
0 @F1@ FAM
1 HUSB @I1@
1 WIFE @I2@
1 MARR
1 CHIL @I3@To get the number of people I would want to import, I wanted to count the number of instances of "1 NAME" entries. I knew that Richard would be able to provide a nice easy answer that wouldn't involve lots of scripting. And of course he pointed me in the direction of grep and wc.The finished product is grep '1 NAME' /Users/jane/Documents/file.GED | wc -l which searches for '1 NAME' amongst the file /Users/jane/Documents/file.GED and then pipes the output into the wc command specifying -l to get the line count.