|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
Stop making mediocre tutorials.The best tutorials are video! Camtasia Studio makes it easy to create engaging, buzz-building screen videos at any size, in any popular format. Download the free trial!
|
|
#1
|
|||
|
|||
|
Please help with sed
Hi,
I have an xml datafile that I need to edit. I assume sed is the best choice but would appreciate your help. I have tried to use sed to edit this file to no avail. My problem is that I have to delete data from each row up to a <tag> and then after the </tag> eg Data-unless-information etc etc<TAG>Useful information in here</TAG>useless information after here I need to return the data between <TAG> and </TAG>. Unfortunately the number of characters will differ so I couldn't use the simple 'delete first x characters of each line'. I really, really need your help with this one! Thanks Rich |
|
#2
|
|||
|
|||
|
Code:
cat oldfile | sed 's/^.*<tag>//' | sed 's/<\/tag>.*$//' > newfile |
|
#3
|
|||
|
|||
|
not really:
sed -ne '/.*tag>/,/.*\/tag>/p' input | sed -e '/.*tag>/d' >output sed, grep, lp .... can open files, no need of cat |
|
#4
|
|||
|
|||
|
Variation but same question
Quote:
I have similar question w/ a modification Code:
Need this data here <start> This is junk on line 2 </start> More good stuff I can't seem to work the multiline issue out. |
|
#5
|
|||
|
|||
|
Try:
Code:
grep ">" myfile | sed -e 's/^.*<tag>//' -e 's/<\/tag>.*$//' > newfile |
![]() |
| Viewing: Dev Shed Forums > Operating Systems > UNIX Help > Please help with sed |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|