not getting any output on some grep command in WSL

Viewed 563

So i just started to learn about grep and i tried to use it on WSL Ubuntu. but some grep commands give no output like the line - grep '123$' sampledata.txt - doesn't provide any output. when i tried this on my Azure vm it works fine. is anyone else facing this issue and is there someway to fix this.

Thank you.

1 Answers

You can remove the CR symbols that come at the end of lines first:

grep '123$' < <(sed 's/\r$//g' sampledata.txt)

In Windows, lines have CRLF endings, in Linux, there are LF endings.

Related