I would like to know who to remove a string or paragraph that are between (((
string )))
Lorem ipsum (((dolor sit amet))), consectetur adipiscing elit. Vestibulum aliquet fringilla est, dictum tempor nunc venenatis at. Sed nec velit sit amet velit cursus imperdiet. Vivamus tincidunt ut nunc quis euismod. Quisque sit amet lorem rhoncus, malesuada justo at, ullamcorper erat.
So "dolor sit amet" should not be in the return
Here's the cmd I have for now which detect the first (((
but then stop…
sed -e "/(((/,/)))/d" file.txt
Best Answer
Doing this for single line strings is very simple:
If you need it to deal with multiline strings, it gets more complex. One approach would be to use
tr
to replace all newlines with the null character (\0
), make the substitution and translate back again:Alternatively, you could just use
perl
:The
-0
causesperl
to read the entire file into memory (this might be a problem for huge files), the-p
means "print each line" but because of the-0
, the "line" is actually the entire file. Thes///
is the same idea as forsed
.