![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Forum Rules | FAQ | Contribute | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts here. |
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| SED Search Pattern and Replace with the Pattern | racbern | Shell Programming and Scripting | 4 | 03-15-2008 01:59 AM |
| Search Mulitiple String pattern in a file | krishnan_6015@y | Shell Programming and Scripting | 2 | 11-23-2007 12:03 AM |
| How to search a pattern inside a zipped file ie (.gz file) with out unzipping it | senraj01 | Shell Programming and Scripting | 2 | 04-26-2006 01:32 AM |
| Search a file for pattern? | davjoyce | UNIX for Dummies Questions & Answers | 2 | 03-07-2006 02:07 PM |
| Search file for pattern and grab some lines before pattern | frustrated1 | Shell Programming and Scripting | 2 | 12-22-2005 11:41 AM |
|
|
Submit Tools | LinkBack | Thread Tools | Display Modes |
|
|||
|
File search for pattern - script
Hi All,
I have two directories as 1) mi/job -> job1.sh, job2.sh, job3.sh 2) mi/sysin -> sysin1, sysin2, sysin3,sysin4 I want to wrrite a script such that it should accept two parameters as directory paths. $ myscript mi/sysin mi/job. The script should be able to scan all files in the 2nd parameter mi/job for occurence of files existing in the 1st parameter. i.e it should scan job1.sh, job2.sh,... for occurences of sysin1, sysin2,... It should print these occurences. Also, it should search in the 2nd parameter for the occurence of another script name, except for the script itself. i.e it should check for occurence of sysin1 in sysin2, sysin3,... [all files in the same directory except sysin1[ It should print all these occurences too. Thanks, Rahul. |
| Forum Sponsor | ||
|
|
|
|||
|
I am not very much clear about what you are looking for. do you want to find the filenames(mi/sysin files) present in your shell programs(mi/job)???
However on a grander basis you could try to start this way. ls $1 >output for filename in `cat output` do grep $filename $2 >temp.$$ ###whatever you want to do here done |
|
|||
|
I guess this should work...I'm trying with passing different arguments. Let's see.
Code:
rm -f Output.txt
touch Output.txt
rm -f FinalOutput.txt
touch FinalOutput.txt
ls $1 | cut -d" " -f1 | while read line
do
find $1 –exec grep –r - -exclude=$1 $line {} ?; -print >> Output.txt
b=`grep -i "$line" Output.txt`
if [ "$b" != "" ]; then
echo "Value is present in the file"
else
#echo "Value is not present in the file"
echo $line >> FinalOutput.txt
fi
done
|
|||
| Google The UNIX and Linux Forums |