Thursday, 19 September 2013

keep the first part and delete the rest on a specified line using sed

keep the first part and delete the rest on a specified line using sed

I know a line number in a file, wherein I want to keep the first word and
delete the rest till the end of the line. How do I do this using sed ? So
lets say, I want to go to line no 10 in a file, which looks like this -
goodword "blah blah"\
and what i want is
goodword
I have tried this - sed 's/([a-z])./\1/'
But this does it on all the lines in a file. I want it only on one
specified line.

No comments:

Post a Comment