How do I search for anything between these tags, I would like to list all occurences where there is some value between the f:facet xml element
<f:facet name="header">Name</f:facet>
How do I search for anything between these tags, I would like to list all occurences where there is some value between the f:facet xml element
<f:facet name="header">Name</f:facet>
if every f:facet
tag is on a separate line then you can do like this:
cat file.xml | sed -ne 's/<f:facet[^>]*>//;s/<\/f:facet>//p'|grep Name
if you want to look across multiple files you can do:
find . -type f| xargs sed -ne 's/<f:facet[^>]*>//;s/<\/f:facet>//p'
This will list whatever occurs between the <f:facet>
tags:
sed 's/<f:facet[^>]*>\([^<]*\)<\/f:facet>/\1/'
This test:
echo '<f:facet name="header">Name</f:facet>' | sed 's/<f:facet[^>]*>\([^<]*\)<\/f:facet>/\1/'
Outputs this:
Name
To run it on all files in the current directory:
sed 's/<f:facet[^>]*>\([^<]*\)<\/f:facet>/\1/' *
To run it on all files in all directories under a common one:
find /path/to/common -type f -print0 | xargs -0 sed 's/<f:facet[^>]*>\([^<]*\)<\/f:facet>/\1/'
If you're running find
from a Windows CMD.EXE prompt, you're probably getting the Windows FIND.EXE
which is giving you that error message. Try find --help
and find /?
. The former is GNU find
and the latter is Windows. If the former gives you an error message and the latter gives you help text, then that will confirm the problem.
You will need to start an instance of Cygwin instead.