0

I have this shell script that works as expected.

#!/bin/sh
for ID in `cat comment_g.txt`
do
rg -w $ID wordsuc.txt >> out.txt
done

But the following grep command does not return a single record.

rg -w -f  comment_g.txt wordsuc.txt > out2.txt

Isn't this command same as the shell script?


Update:

works as expected:

# cat comment_g.txt
and

# cat ordsuc.txt
this
that
more and

# rg -w -f comment_g.txt ordsuc.txt
3:more and

# grep -w -f comment_g.txt ordsuc.txt
more and

Does not work same as above:

# cat comment_g.txt
सदस्य

# cat ordsuc.txt
सदस्य आणि
नोंद
पूर्व संकल्पनांना बळी पडले आहेत

# incorrect, should return 1 line
# rg -w -f comment_g.txt ordsuc.txt

# correct output:
# > out.txt
# sh run.sh
# cat out.txt
सदस्य आणि
shantanuo
  • 31,689
  • 78
  • 245
  • 403

0 Answers0