whatisthis987
IS-IT--Management
Hi,
I would like to search between "aaa" and ";" for "ccc ddd" and replace it with a blank. To me, each "line" of interest begins with "aaa" and ends with a semicolon ";".
For example,
aaa 111 222 ccc ddd;
sdfs fdd ccc ddd;
sfsdf dfdf fdf dfff
dfsdfs fdfd;
aaa dfg ccc ccc ddd;
aaa ddd ccc ccc ddd;
aaa dfg dffd dfdfd
sdfdsf dfdf dfd fdgdfg
dfgdg dfgd dgfd gdgdf
fdsfs ccc ddd;
basas sdsa asda ccc ddd;
basas sdsa asda ccc ddd;
basas sdsa asda ccc ddd;
aaa 111 222 ccc ddd;
Desired output is:
aaa 111 222;
sdfs fdd ccc ddd;
sfsdf dfdf fdf dfff
dfsdfs fdfd;
aaa dfg ccc;
aaa ddd ccc;
aaa dfg dffd dfdfd
sdfdsf dfdf dfd fdgdfg
dfgdg dfgd dgfd gdgdf
fdsfs;
basas sdsa asda ccc ddd;
basas sdsa asda ccc ddd;
basas sdsa asda ccc ddd;
aaa 111 222;
I tried, sed '/aaa/,/;/s/ ccc ddd//g' FILE but the 2nd line of the output is wrong. It shouldn't have changed.
aaa 111 222;
sdfs fdd;
sfsdf dfdf fdf dfff
dfsdfs fdfd;
aaa dfg ccc;
aaa ddd ccc;
aaa dfg dffd dfdfd
sdfdsf dfdf dfd fdgdfg
dfgdg dfgd dgfd gdgdf
fdsfs;
basas sdsa asda ccc ddd;
basas sdsa asda ccc ddd;
basas sdsa asda ccc ddd;
aaa 111 222;
Any ideas?
I would like to search between "aaa" and ";" for "ccc ddd" and replace it with a blank. To me, each "line" of interest begins with "aaa" and ends with a semicolon ";".
For example,
aaa 111 222 ccc ddd;
sdfs fdd ccc ddd;
sfsdf dfdf fdf dfff
dfsdfs fdfd;
aaa dfg ccc ccc ddd;
aaa ddd ccc ccc ddd;
aaa dfg dffd dfdfd
sdfdsf dfdf dfd fdgdfg
dfgdg dfgd dgfd gdgdf
fdsfs ccc ddd;
basas sdsa asda ccc ddd;
basas sdsa asda ccc ddd;
basas sdsa asda ccc ddd;
aaa 111 222 ccc ddd;
Desired output is:
aaa 111 222;
sdfs fdd ccc ddd;
sfsdf dfdf fdf dfff
dfsdfs fdfd;
aaa dfg ccc;
aaa ddd ccc;
aaa dfg dffd dfdfd
sdfdsf dfdf dfd fdgdfg
dfgdg dfgd dgfd gdgdf
fdsfs;
basas sdsa asda ccc ddd;
basas sdsa asda ccc ddd;
basas sdsa asda ccc ddd;
aaa 111 222;
I tried, sed '/aaa/,/;/s/ ccc ddd//g' FILE but the 2nd line of the output is wrong. It shouldn't have changed.
aaa 111 222;
sdfs fdd;
sfsdf dfdf fdf dfff
dfsdfs fdfd;
aaa dfg ccc;
aaa ddd ccc;
aaa dfg dffd dfdfd
sdfdsf dfdf dfd fdgdfg
dfgdg dfgd dgfd gdgdf
fdsfs;
basas sdsa asda ccc ddd;
basas sdsa asda ccc ddd;
basas sdsa asda ccc ddd;
aaa 111 222;
Any ideas?