I have a file abc.txt that I am searching for the occurence of the string STR ...
I am using the command in a script
cat abc.txt | grep $STR
It identifies each space as a seperator and prints word by word.
How to suppress the space when searcing with grep?
It works only when I use the string itself in the command and not the varible name [ It works when I say cat abc.txt | "This is a test message" ]
How do I solve this issue. I appreciate your help.
> cat search_str
#! /bin/bash
sstring="This is a test message"
echo "Marker #1"
cat abc.txt
echo "Marker #2"
cat abc.txt | grep $sstring
echo "Marker #3"
cat abc.txt | grep "$sstring"
> search_str
Marker #1
This is a test message
This is not the right message
Neither is this
Could this be one?
This is not a test message
And one last
This is a test message
Marker #2
grep: can't open is
grep: can't open a
grep: can't open test
grep: can't open message
Marker #3
This is a test message
This is a test message
>