in reply to Wish to keep only those lines which start with letter s, and delete all other lines.

caution: the following code does an in-place edit. make sure to back up ( well, the -i.bak does it for you, but it can't hurt to be careful )

perl -i.bak -pe 's/^[^s].*\z//' file
  • Comment on Re: Wish to keep only those lines which start with letter s, and delete all other lines.
  • Download Code