samedi 9 mai 2015

Grep\Sed between two tags with multiline

I have many files with whom I need to get information.

Example of my files:

first file content:

"test This info i need grep</singleline>"

and

second file content (with two lines):

"test This info=
 i need grep too</singleline>"

in results i need grep this text: from first file - "This info i need grep" and from second file - "This info= i need grep too"

in first file i use:

grep -o 'test .*</singleline>' * | sed -e 's/test \(.*\)<\/singleline>/\1/'

and successfully get "This info i need grep" but I can not get the information from the second file by using the same command. Please help rewrite the command or write what the other. Very big thanks!

Aucun commentaire:

Enregistrer un commentaire