Issue
I need to find a line in a file that starts with an a and the last word in the line ends with an e.
How can I do it with a tool like grep
?
Solution
Just say this:
grep '^a.*e$' file
This means: look for those lines starting (^
) with a
, then 0 or more characters and finally and e
at the end of the line ($
).
Test
$ cat a
hello
and thisfinishes with e
foo
$ grep '^a.*e$' a
and thisfinishes with e
Answered By - fedorqui Answer Checked By - David Goodson (WPSolving Volunteer)