You're viewing a comment by Peter Krumins and its responses.

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'

Reply To This Comment

(why do I need your e-mail?)

(Your twitter handle, if you have one.)

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

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