LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   help with sed (https://www.linuxquestions.org/questions/programming-9/help-with-sed-329576/)

signalno9 06-02-2005 10:23 AM

help with sed
 
Hello, I'm having difficulty removing text enclosed in brackets from lines with sed.

For example, if I echo the following line:

Jun 2 08:28:37 host kernel: word1 word2 [word3] word4 [word5] word6

to sed "s/\[.*\]//g", sed removes words 3-5. The desired effect is that I want to only remove words 3 and 5. I know sed is doing exactly what I am telling it to. How to I tell it to do what I want?

Thanks for the help!

signalno9 06-02-2005 11:42 AM

got it, thanks anyway

sed -e 's/\[[^]]*]//g'


All times are GMT -5. The time now is 10:58 AM.