need shell script to find a word

January 22, 2010 at 14:09:21
Specs: Windows Vista
How do i write a shell script that find a word
1.the script accepts morethan 2 words to find and morethan 2 files to search.and displays the result.

See More: need shell script to find a word

Report •

#1
January 23, 2010 at 04:12:42
write a shell script
OS: Windows Vista

Are you looking for a batch file/command script (Windows), or a Bash shell script (Linux/UNIX)?


Report •

#2
January 23, 2010 at 05:29:31
Let's assume Windows ...


C:\Temp>type text1.txt
b
this is a test

C:\Temp>type text2.txt
b
yes, this is really a test
C:\Temp>findstr /C:"a test" text1.txt text2.txt
text1.txt:this is a test
text2.txt:yes, this is really a test
C:\Temp>


Report •

#3
January 23, 2010 at 12:15:20
Hi thanks for your reply..
iam looking for bash shell script(Unix)

Report •

Related Solutions

#4
January 23, 2010 at 17:16:07
do you want to search EACH file for EVERY word, or match word to file on one-to-one basis? This does the first option
(all files searched for all words)
n=0
until [ -z $test1 ] ; do {
echo -n string:
read test1
((n+=1))
a[$n]=$test1
}
done
test1=a
until [ -z $test1 ] ; do {
echo -n file:
read test1
((h+=1))
b[$h]=$test1
}
done
for (( q=1;q!=h;q+=1 )) ; do {
for (( m=1;m!=n;m+=1 )) ; do {
echo ======= FILE: ${b[$q]} ====== STRING: "${a[$m]}"
fgrep "${a[$m]}" ${b[$q]} ;
}
done
}
done


Report •

#5
January 23, 2010 at 21:23:19
Thank you so much...

Report •

Ask Question