Need help with SED command
Hi,
I have been trying to remove few lines of text in a file - I basically want to remove the following - Code:
<?xml version="1.0" encoding = "iso-8859-1"?> I used this command Code:
sed '/<?xml\/version"/,/-->/d' article1.txt > u.txt |
Code:
sed '/<\?xml\/version"/,/-->/d' article1.txt > u.txt |
Quote:
|
If you want to edit the file in place, use the -i option. Be careful with that: if you are not really sure that the result is exactly what you're trying to do, the loss of the original file is at risk. Anyway, you can use the -i option in the following way to do a safe backup copy:
Code:
sed -i.bck 'blah blah blah' file |
Quote:
Code:
sed -i '/<\?xml\/version"/,/-->/d' article1.txt > u.txt What could be wrong? |
What's with all the escaping? I just used the following:
Code:
sed '/<?xml version/,/-->/d' file Code:
sed '/<?xml version/,+6d' file Code:
sed -n '/<?xml version/,+6p' file |
Quote:
|
As David said! :)
|
Quote:
|
Quote:
In fact, in basic mode, escaping the question mark actually enables the extended regex functionality! The grep manpage goes into more detail about the differences between basic and extended regex, since it works the same way. |
i see thanks for the info.
|
Anyone who can remember all the differences between regular and extended Regexes---AND how those differences vary among programs---is worthy of sainthood.
I have developed a simple approach: Trial and Error |
I highly recommend the OWL book http://regex.info/
|
Indeed ... Friedl is a genius :}
|
All times are GMT -5. The time now is 12:18 PM. |