Originally Posted by dots
I wondered how clear my description was. My data has phone numbers instead of social security numbers. Sorry about that, I looked at it wrong.
Example line of data:
John Doe:123-456-7890:123 Something Lane, Somewhere, TX, 12345:1/12/77:50000
I need to search by the name and change the birth date(1/12/77 in the example). How do I substitute a date for the one that is there when I'm not sure if there are one or two digits in the month and day?
I gave you an example above:
sed '/John Doe/ s|[0-9][0-9]*/[0-9][0-9]/[0-9][0-9]|21/03/74|g' file
It will replace 1/12/77 (or 01/12/77) with 21/03/74 on the line containing 'John Doe'.
It looks for the following pattern:
1 or 2 digits / 2 digits / 2 digits
[0-9]* - it means 0 or 1 instance of the pattern preceding * (the asterisk)
In that case it's 0 or 1 digit. So [0-9][0-9]* will match 1 or 2 digits.
I hope what I'm saying makes sense.