Thursday, October 14, 2010

extracting social security number from an xml file using grep and cut

file.txt
<field10>123-45-6789</field10>
<field10>123-45-6789</field10>
<field10>123-4-6789-</field10>

here is the regexp

([0-9]+-)+[0-9]+<
and the command is 
grep -o '\([0-9]\+-\)\+[0-9]\+<' file.txt | cut -d "<" -f 1

No comments:

Blog Archive