4 Added more info
source | link

You need to use a herestring (<<<) here to pass the string as input to grep, herestring returns a file descriptor, grep can then operate on that:

$ grep -ni "^li" <<<"linux
loan
litmus
launch"

Output:

1:linux
3:litmus

If your shell doesn't support herestrings, many shells don't, you can print your string and pipe it to grep:

$ echo "linux
loan
litmus
launch" | grep -n -i "^li"
1:linux
3:litmus

Or use heredoc (<<):

$ grep -ni "^li" <<EOF
> linux
> loan
> litmus
> launch
> EOF
1:linux
3:litmus

You need to use a herestring (<<<) here to pass the string as input to grep, herestring returns a file descriptor, grep can then operate on that:

$ grep -ni "^li" <<<"linux
loan
litmus
launch"

Output:

1:linux
3:litmus

If your shell doesn't support herestrings, many shells don't, you can print your string and pipe it to grep:

$ echo "linux
loan
litmus
launch" | grep -n -i "^li"
1:linux
3:litmus

You need to use a herestring (<<<) here to pass the string as input to grep, herestring returns a file descriptor, grep can then operate on that:

$ grep -ni "^li" <<<"linux
loan
litmus
launch"

Output:

1:linux
3:litmus

If your shell doesn't support herestrings, many shells don't, you can print your string and pipe it to grep:

$ echo "linux
loan
litmus
launch" | grep -n -i "^li"
1:linux
3:litmus

Or use heredoc (<<):

$ grep -ni "^li" <<EOF
> linux
> loan
> litmus
> launch
> EOF
1:linux
3:litmus
3 typo
source | link

You need to use a herestring (<<<) here to pass the string as input to grep, Heredocherestring returns a file descriptor, grep can then operate on that:

$ grep -ni "^li" <<<"linux
loan
litmus
launch"

Output:

1:linux
3:litmus

If your shell doesn't support herestrings, many shells don't, you can print your string and pipe it to grep:

$ echo "linux
loan
litmus
launch" | grep -n -i "^li"
1:linux
3:litmus

You need to use a herestring (<<<) here to pass the string as input to grep, Heredoc returns a file descriptor, grep can then operate on that:

$ grep -ni "^li" <<<"linux
loan
litmus
launch"

Output:

1:linux
3:litmus

If your shell doesn't support herestrings, many shells don't, you can print your string and pipe it to grep:

$ echo "linux
loan
litmus
launch" | grep -n -i "^li"
1:linux
3:litmus

You need to use a herestring (<<<) here to pass the string as input to grep, herestring returns a file descriptor, grep can then operate on that:

$ grep -ni "^li" <<<"linux
loan
litmus
launch"

Output:

1:linux
3:litmus

If your shell doesn't support herestrings, many shells don't, you can print your string and pipe it to grep:

$ echo "linux
loan
litmus
launch" | grep -n -i "^li"
1:linux
3:litmus
2 Added another option
source | link

You need to use a Heredocherestring (<<<) here to pass the string as input to grep, Heredoc returns a file descriptor, grep can then operate on that:

$ grep -ni "^li" <<<"linux
loan
litmus
launch"

Output:

1:linux
3:litmus

If your shell doesn't support herestrings, many shells don't, you can print your string and pipe it to grep:

$ echo "linux
loan
litmus
launch" | grep -n -i "^li"
1:linux
3:litmus

You need to use a Heredoc (<<<) here to pass the string as input to grep, Heredoc returns a file descriptor, grep can then operate on that:

$ grep -ni "^li" <<<"linux
loan
litmus
launch"

Output:

1:linux
3:litmus

You need to use a herestring (<<<) here to pass the string as input to grep, Heredoc returns a file descriptor, grep can then operate on that:

$ grep -ni "^li" <<<"linux
loan
litmus
launch"

Output:

1:linux
3:litmus

If your shell doesn't support herestrings, many shells don't, you can print your string and pipe it to grep:

$ echo "linux
loan
litmus
launch" | grep -n -i "^li"
1:linux
3:litmus
1
source | link