I have a text which includes multiple substrings like :xxx: which should be removed using awk. The xxx-part could be any string but cannot contain white spaces or line breaks.
Here is an example text:
This is sample text:hello:
It might include normal colons like : or: that have to remain. :hello-world:
The command should turn that text into:
This is sample text
It might include normal colons like : or: that have to remain.
My pathetic attempt:
awk '{gsub(":.*:","")}1'
>Solution :
Using sed
$ sed 's/:[^ \|:]*://g' input_file
This is sample text
It might include normal colons like : or: that have to remain.
Using awk
$ awk -F":[^:| ]*:" '{print $(NF-1)}' input_file
This is sample text
It might include normal colons like : or: that have to remain.