0

My small file contains this information line by line:

abc.123
abc.258
abc.952

I wanted to get those lines matching in my bigger file (~30Gb). I tried this command but it didn't give me any result.

grep -f small.txt big.txt

I have tested all abc.123, abc.258 and abc.952 does exist in my bigger file, meaning that I tried to grep each of these names one by one it gave me the exact result I want.

grep "abc.123" big.txt

I have no idea where I could possibly go wrong?

Cyrus
  • 84,225
  • 14
  • 89
  • 153
M Shen
  • 51
  • 5
  • Add output of `file small.txt` to your question (no comment here). – Cyrus Mar 06 '22 at 22:51
  • 1
    Your `small.txt` may have DOS line endings. If so, fix it with [dos2unix](https://sourceforge.net/projects/dos2unix/). – tshiono Mar 06 '22 at 23:04
  • 1
    @tshiono thank you, after converting, it works perfectly. is there a way to avoid this happening when creating a txt file? I built via nano btw – M Shen Mar 06 '22 at 23:18
  • 1
    `cat -A` will show line ending characters on the screen. I'm not so familiar with `nano` but it will notice the file is in `DOS Format` when reading and writing. You can toggle the mode with keying `Meta-D` or `Alt-D`. – tshiono Mar 06 '22 at 23:34
  • You can use `dos2unix some_file.txt` to change the line endings. – Nic3500 Mar 07 '22 at 04:39

0 Answers0