Linux shell, get all the matches from a file -
this question has answer here:
- awk extract multiple groups each line 4 answers
i have file following format:
line 1 line 2 <% word1 %> text <% word2 %> line 3 <%word3%>
i want use linux shell tools awk, sed etc words quoted in <% %>
result should like
word1 word2 word3
thanks help.
i forgot mention: in embedded environment. grep has no -p option
using awk:
awk -f '<% *| *%>' '{for(i=2; i<=nf; i+=2) print $i}' file word1 word2 word3
Comments
Post a Comment