Shell Script grep The Same Word In 2 Files
cat test1.txttest001
test002
test003
test004
test005
cat test2.txt
test003
test004
test005
test006
./grep-word-2-files.sh
test003
test004
test005
cat grep-word-2-files.sh
#!/bin/bash
rm -rf /home/vannak/diff/match-word.txt
for i in `cat /home/vannak/diff/test1.txt`
do
grep $i /home/vannak/diff/test2.txt >> /home/vannak/diff/match-word.txt
done
cat /home/vannak/diff/match-word.txt
No comments:
Post a Comment