script help
hello im trying to output a large amount of data from a text file and im not sure how to do this i want to output the text between two words for example if the words where "test>" and "<info" and i had this file
Code:
test>test1<info Code:
test1 |
Hi,
Sed will do it... sed 's/test>\(.*\)<info/\1/g' file.txt |
Code:
sed 's/test>\(.*\)<info/\1/' <file> |
If you actually have a delimiter like ">" or "<", you could also use "cut":
In your example: cut -d'>' -f2 file |cut -d'<' -f1 should do the trick too. |
thanks a lot that works all apart from one problem it seems out output the text on the line after <info for example if i have
Code:
test>test1<info Code:
test1 sed -n 's/test>\(.*\)<info/\1/gp' <file> to filter out other lines but i cant seem to work this last part out |
I went a step more and put some text in front also....
Code:
test>test1<info Code:
sed 's/.*test>\(.*\)<info.*/\1/g' file.txt |
yay it works thanks for your help and i think im slowley starting to understand this command as well
|
You're welcome! :)
|
All times are GMT -5. The time now is 08:42 PM. |