Link to home
Start Free TrialLog in
Avatar of kphillips1
kphillips1Flag for United States of America

asked on

need to enter dashs into a string of characters "123456789" using sed result s/b "123-45-6789"

Have an ascii file that contains lines of data in the format:
 
12345~123456789~
12346~023456789~
 
Need to place dashes into send string of numbers to format a social security number
 
123-45-6789
023-45-6789
 
Would like to do this on the command line using sed, if possible. The data would be piped to the sed command.
ASKER CERTIFIED SOLUTION
Avatar of fim32
fim32

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of kphillips1

ASKER

Yes I would like the output to be:  "12345~123-45-6789"
 
The data is a listing of client ids and there order numbers
Avatar of fim32
fim32

so you want the output to remove the trailing ~?

then:
sed -e 's/\(~...\)\(..\)\(....\)~/\1-\2-\3/;'