i am asking for your help please.
I reviewed a lot of sources and did some testing with awk and sed, but i can't get it to work. Below is a snippet of a config file which i could get an output via grep, but not the way i need it.
> file.txt
>
> "<property>name="DBName"><value>ABC</value>name="DBName"><value>DEF</value></property>
>
> cat file.xml | grep -o -P '.name="DBName"><value>.{0,20}'
> name="DBName"><value>ABC</value>
> name="DBName"><value>DEF</value></propert
The desired output is:
ABC
DEF
Thanks for any help.
Andi
>
and add the relevant snippets of the filefile.xml
apart of thegrep
command. The best approach for XML files generally is to use tools designed for parsing that format likexmllint
(approach valid for other structured formats like JSON).<
are missing before bothname=
. Can you, please, clarify ? Apart from this, you don't need tocat someFile | grep [options]
, you can directlygrep [options] someFile
.files.txt
but then your code catsfile.xml
and your file.txt has lines in double quotes but missing some<
s, etc. Please clean up your question to clearly show us the actual input you need help parsing. I suspect you have a file.xml which you're doing some pre-processing on to create file.txt and are now asking for help to do further processing on - don't do that as it's unlikely to be the best approach, just show the contents offile.xml
and the desired final output.