Sample file : abc.ksh
echo "This is a sample file." >> mno.txt
echo "\nThis line has new line char." >> mno.txt
I want
echo "\nThis line has new line char." >> mno.txt
as output.
Sample file : abc.ksh
echo "This is a sample file." >> mno.txt
echo "\nThis line has new line char." >> mno.txt
I want
echo "\nThis line has new line char." >> mno.txt
as output.
Regular expression pattern search
Easiest way is using REGEX:
In REGEX language,
$
means EOL (end of line), so it will often match"\n"
(cause is very common as the end of line).WARNING: be careful to use versions of
grep
that support REGEX!.Use
-F
to match fixed strings:From
man grep
:You may try like this by escaping the backslash with another backslash:
Simply escape the backslash with another backslash and put the regex in single quotes so the shell does pass it to grep without handling the backslashes itself: