Im building a script to load from a file content and then use to cat and grep in another file. The problem is that is not showing any values while executing the grep. If i do the command manually it will retrieve the data.
i already use the while but the issue is the same. the output6.txt is always empty. the echo seems to work, so it seems to be the grep or cat issue.
Sample from BlockspamCLIs.txt i have the values:
4412345
441236
2367890
Sample All_events.csv file
1,441236,20220909120909,test
2,441237,20220909120909,test
3,441232,20220909120909,test
4,44136,20220909120909,test
5,2367890,20220909120909,test
As an output im expecting to retrieve and store and record inside of the CSV file that contains the number for example:
1,441236,20220909120909,test
5,2367890,20220909120909,test
my script:
for i in `cat BlockspamCLIs.txt`
do
grep $i *_All_events.csv >> output6.txt
echo $i
done
thank you in advance.
grep
is that you can't easily restrict the match to the 2nd field only. The string202209
would, for example, match all lines that we are given. – Kusalananda Sep 28 '22 at 08:49BlockspamCLIs.txt
in Windows? If so, that's your problem: windows line endings. Fix the file withdos2unix BlockspamCLIs.txt
orsed -i 's/\r//' BlockspamCLIs.txt
and try again. – terdon Sep 28 '22 at 09:02