Linux shell, get all the matches from a file -


this question has answer here:

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

Popular posts from this blog

java - Run a .jar on Heroku -

java - Jtable duplicate Rows -

validation - How to pass paramaters like unix into windows batch file -