You're replying to a comment by Peter Krumins.

February 14, 2013, 00:39

Yes, that's because .* is greedy.

This \(,DATE.*\),* matches ,DATE_PROG1,DATE_PROG2, and replaces it with ,DATE_PROG1,DATE_PROG2 "HELLO".

There is no way to make .* non-greedy in sed. You've to use [...]* trick:

$ echo $TAB_COLS | sed -e 's/\(DATE[^,]*\)/\1 \"HELLO\"/g'
ID,TITLE,DATE_PROG1 "HELLO",DATE_PROG2 "HELLO"

Reply To This Comment

(why do I need your e-mail?)

(Your twitter handle, if you have one.)

Type the word "0day_95": (just to make sure you're a human)

Please preview the comment before submitting to make sure it's OK.