I'm doing some integrity checeking. I Have found if the file contains an "invalid" entry (Zipcode +4). What I'm looking to do is modify the data so that it's just the 5 digit zipcode. I found a couple of helpful posts, but nothing that I could apply to my situation.
Here's a sample input (note that there could be multiple entries per file, and it would appear as one line)
<Name> Joe</Name><LName>Smith</LName><Zipcode>12345-7132</Zipcode>
I'd like to rewrite the Zipcode data to just be <Zipcode>12345</Zipcode>
This is the grep I'm using to determine if an invalid zipcode exits
But once I've found it, that's where I'm stuck. I would think sed, but in what I found that was more useful if you knew what your before and after values were...since mine are dynamic, I didn't know how to proceed
/g just means 'global search/replace', allowing it to do more than one replacement per line. Without it, it would only replace the first match in a line.