how can i delete columns beginning and ending with parenthesis in a file
Expectd Input - content of input.txt
ABC (BCD) EFG
Based on the solution from @slitvinov:
BEGIN {
RS = "[[:space:]]"
ORS = ""
eat = 0
}
/^\(.*\)$/ {
next
}
/^\(/ {
eat = 1
next
}
/\)$/ {
if (eat) {
eat = 0
next
}
}
{
if (eat)
next
print $0 RT
}
That to an .awk
file and awk -f foo.awk foo.txt
gives:
ABC EFG
BCD
DEF BCD
EFG HI(JKL)
ABC EFG LMN
But I think it could be done simpler...