Bash grep command starts with or ends with

bash, grep, terminal, unix

Solution

try this:

grep "^in\|in$" input.txt

by default, grep use `BRE`, you have to escape the `|`. Or use grep's `-E or -P`, in order to avoid escaping those char with special meaning.

P.S, the `cat` is no necessary.

Problem

I'm after a command that will return results based on a pattern match that starts with or ends with a the given pattern. This is what i have so far. ``` "cat input.txt | grep "^in|in$" ``` My main problem is that i cant get the (or) to work but i can get them to work individually. Thanks for your help in advance.

Original source