1

I am just started learning used of SED and I want to delete strings between given two pattern excluding the second pattern matching.

In Details: Assume We are having string in file:

Name Rohit
   profession = student
   place = bangalore
   like = game
Name Ravi
   profession = working
   place = chennai
   like = xyz

If I have provided Name Rohit value then I have to delete all the information available for Rohit.

for input = Rohit

output will be:

Name Ravi
   profession = working
   place = chennai
   like = xyz

I tried below sed command:

 sed "/^\s*Name Rohit/,/^\s*Name/d" del.txt

and Name of another person is also getting deleted as below:

profession = working
place = chennai
like = xyz

Can anyone here help me resolved this issue. Thanks in advance!

Cyrus
  • 84,225
  • 14
  • 89
  • 153
Rohit
  • 406
  • 1
  • 5
  • 21

0 Answers0