[PLUG] Text Reformatting

Rich Shepard rshepard at appl-ecosys.com
Thu Dec 13 22:53:35 UTC 2012


On Thu, 13 Dec 2012, Scott Bigelow wrote:

> I think sed is up to the task, here's one way to do it without busting out
> a scripting language:
>
> sed -e
> 's#\([[:digit:]]\{2\}\)/\([[:digit:]]\{2\}\)/\([[:digit:]]\{4\}\)#\3-\1-\2#'
>
> It looks like a mouthful, but it's really quite simple; it just matches
> AA/BB/CCCC and makes it CCCC-AA-BB. If you get false matches within other
> columns, you could try anchoring against the comma that bounds the field.

   Thanks, Scott. As I walked the dog just now (the other one's tight asleep
on the bed) it occurred to me that sed should be able to do the job. I'm
still a novice with sed and awk so I greatly appreciate the lesson!

Rich




More information about the PLUG mailing list