Skip navigation

Presented as an exercise in figuring out what I was trying to accomplish:

sed -e 's/\([ ]*[0-9]\{4,4\}\)\([ ]*\)\([^ ]*\)\([ ]\)\(.*\)/\1,\5,\3/g'

Anyone (other than Dave) with an idea of what I’m doing here, leave your answers in the comments.

Advertisements

4 Comments

  1. ooo regex challenge!

    stream edit sub: spaces, four digits, spaces, a word, space, then the rest of the line
    with
    spaces, four digits, [comma], the rest of the line, [comma], the word

    switching someone’s first and last name?

    • Yep, for an updated phone list on campus (the four digits are the extension). Our voip box doesn’t give an option to generate a nice-looking list on its own, so I had to do it the fun way and generate a csv that other people could work with in Excel.

      • AH HA! Well actually I came to the conclusion that the digits were id numbers. I think you’re hurting yourself…so much capture

      • I’m sure that I could optimize the thing and probably will at some point, but the quick and dirty way was best for a ticket that wantwd filling in the next hour.


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: