Delete a set of lines after finding a text
Hi All,
I need to delete a set of lines below the search word. For Ex, i have file similar to this: cat 1 2 3 4 6 rat a b y r e cat y u t bat u t e w in this case i need to search for cat and delete 3 lines immediately below that. The result must look like 4 6 rat a b y r e bat u t e w |
Homework??
Take a look at the address range syntax for SED (In the man page or the official manual at http://www.gnu.org/software/sed/manual/) example: sed -n '/dog/,+3p' filename prints only the first line containing "dog", + the next 3 lines |
Code:
awk '/cat/{ for(i=1;i<=3;i++) getline; next}1' file |
Thanks ghostdog74
ghostdog74,
Thanks a lot for your quick reply & solution. It really works |
All times are GMT -5. The time now is 08:49 PM. |