Click here to Skip to main content
15,895,011 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Assume a file with below contents
$cat file1
Line1
Line2
Something!
Line3

Now I wanted to search keyword 'Line' and delete only the second matching line i.e., 'Line2'

I am aware to delete all the matching lines as below.

$sed -i '/Line/d' file1

Please help me!!
Posted
Comments
Richard MacCutchan 19-Nov-15 7:58am    
You could try looking at awk and grep as more powerful commands for this sort of task.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900