Quantcast
Channel: UNIX and Linux Forums
Viewing all articles
Browse latest Browse all 16232

sed to add word if pattern exists

$
0
0
Hi,

I have a file with data listed below:

Code:

clm_id double,
cnl_id double,
cnl_amt double

I want output to be
Code:

clm_id string,
cnl_id string,
cnl_amt double

So replace double by string if the field contains the word _id

I tried
Code:

sed -e 's/_id/& string/' filename
The above will not delete double.

I can add one more comand and delete double, but I want to do it in same command if possible

Thanks
Moderator's Comments:
Please use CODE (not ICODE) tags when displaying full line and multi-line sample input, output, and code.
Use ICODE tags for fixed width font within a line of text.

Viewing all articles
Browse latest Browse all 16232

Trending Articles