[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: diff files matching a pattern



Kamaraju S Kusumanchi wrote:
Eduardo M KALINOWSKI wrote:
for i in `seq 1 50`; do diff dir1/file$i.txt dir2/file$i.txt >
diff$i.txt ; done


Ok, this works on the command line. But I am looking for something along the
lines of

bash_script_name dir1/pattern1 dir2/pattern2


where dir1/pattern1, dir2/pattern2 are given as arguments to the script. I
could not figure out how to do this inside a bash script. Any idea?

#call as script-name <pattern> dir1 dir2
pattern="$1"
dir1="$2"
dir2="$3"
for file in $dir1/$pattern; do
    diff $file dir2${file##${dir1}}
done


raju



--
Raj Kiran Grandhi
--
At the source of every error which is blamed on the computer, you will find at least two human errors, including the error of blaming it on the computer.


Reply to: