Shell script to find common words in the files? Hello,
help everyone help me to find common words in the files. For example, if I have 3 files like:
file 1
12
54
65
67
file 2
23
54
65
66
76
file 3
12
23
34
54
66
and so on ...
These files have special charactersitics such as the words are integers and all are in ascending order.
what would be my production is:
1 file1, file2, file3
2 file1, file2
2 file1, file3
3 file2, file3
where the first column refers to the number of words game. I wrote a file to go on the control of 2 files, which is given below:
#! / Bin / sh
rm-f subst.txt
subst.txt touch
a = 1
while [$ a-le 296]
do
b = `expr $ a + 1"
while [$ b-295]
do
w $ cat a.txt | fgrep-w $ wf b.txt> tmp.txt
p = `wc-l awk tmp.txt | '(print $ 1)`
echo $ p
if (($ p! = 0))
then
echo $ p "p" $ a "w" $ b ",">> subst.txt
else
echo "null"
fi
b = `expr $ b + 1"
fact
a = `expr $ a + 1"
fact
but it would be a stupid idea to extend it with more while loops in the statement condtional, and break when a match is not found.
Can I get a bright idea that? Frankly, I'm not really in shell scripts!
Thank you in advance.
Here's a site that might help you:
http://www.davidpashley.com/articles/wri ...
Posted on May 28, 2010.