Delete text between square brackets and also delete those square brackets using sed or awk

Hi All,

I have a text file which looks like this:

computer programming [A01]
systems engineering [B04.B08.C78]

I want to get rid of these square brackets and also the text that is inside these brackets. So that my final text file looks like this:

computer programming
systems engineering

I am using Linux. Any suggestions?

nawk '{gsub(/\[[A-Z0-9.,]*\]/,""); print; }' file_name
1 Like

U can use below
sed 's/\[.*\]//' file_name

1 Like

+1 @ sed 's/\[.*\]//' file_name

You beat me to it lol.

I was in the reply screen and saw your post but it was not in the thread when I hit reply.

1 Like