quantum231
quantum231

Reputation: 2585

How to use grep to print lines ending with a certain string?

I wanted to print all lines from a file containing "FAIL**". I don't wanted any lines with FAILED or FAILURE to be printed. How do I do this? I want to the output to go into another file.

The lines end with this string.

Upvotes: 0

Views: 5734

Answers (2)

Jotne
Jotne

Reputation: 41446

This awk will also works too:

awk '/FAIL\*\*$/' file

Upvotes: 0

Avinash Raj
Avinash Raj

Reputation: 174696

Your command should be,

grep 'FAIL\*\*$' file

Escape the * chracter to make your grep command to work.

Example:

$ cat file
avi
la FAIL**
FAIL
foo FAIL**
bar FAIL**

$ grep 'FAIL\*\*$' file
la FAIL**
foo FAIL**
bar FAIL**

Upvotes: 1

Related Questions