Awk or grep question -


i have datafile

[abc] def ghi [jkl] [mno] 

from file; can run grep , lines have "[" in them. how can contents of text inside "[]".

for example:

abc jkl mno 

thanks

sed -n 's/\[\(.*\)\]/\1/p' file 

explanation: -n suppresses printing of each line stdout, /p @ end of regex re-enables behavior causing matching lines printed. regex matches between brackets , replaces entire line it.


Comments

Popular posts from this blog

apache - Add omitted ? to URLs -

redirect - bbPress Forum - rewrite to wwww.mysite prohibits login -

php - How can I stop spam on my custom forum/blog? -