0

I want to exclude the last line shows "cwd=/" alone from the following list. Rest I want to display

   1111 cwd=/path/to/file
   1139 cwd=/path/to/file
   1330 cwd=/path/to/file
   1330 cwd=/path/to/file
   2739 cwd=/path/to/file
   3273 cwd=/path/to/file
   9573 cwd=/path/to/file
   9981 cwd=/

What I meant once exluding the last line, I want result as follows:

   1111 cwd=/path/to/file
   1139 cwd=/path/to/file
   1330 cwd=/path/to/file
   1330 cwd=/path/to/file
   2739 cwd=/path/to/file
   3273 cwd=/path/to/file
   9573 cwd=/path/to/file

Any idea how to do that with grep?

2 Answers 2

0

you can use

sed '$d' filename

This is only applicable for removing the last line only..

0

Require a character after the false match.

grep 'cwd=/.'
2
  • wow, thank you :) can you explain how this is working? that dot "." means space after trailing slash?
    – John
    Mar 27, 2015 at 0:10
  • A . in a regex matches any character. Mar 27, 2015 at 2:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.