Sed Problem
I wnat to use sed to change delete some lines in a file, but I dont know how to write the sed script.
The file is: john 2004 hello world hello 2005 peter 2004 goodbye 2005 My target is to delete the line between 2004 and 2005. However when I write sed -e /2004/,/2005/d file All content is deleted. I want to keep the name and year only. How can I write the script? |
Do you mean that you want to delete the lines "hello world", "hello", and "goodbye" but not the lines containing
"2004" and "2005"? This may be a bad way of doing it but here goes: sed '/2004/,/2005/ { /200[45]/!d }' test Inside the braces is a subrange, inside of the main range selection. If the line doesn't contain 2004 or 2005, then it is deleted. |
All times are GMT -5. The time now is 12:42 AM. |