Re: diff files matching a pattern
Raj Kiran Grandhi wrote:
> #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
>
I must be doing something wrong here. Consider this reduced problem. I tried
to write a script to list all the files matching a specific pattern.
Consider
$cat ~/bin/patlist
#! /bin/sh
# to list all the files matching a given pattern
# call as patlist <pattern>
pattern="$1"
for file in $pattern; do
echo $file
done
$ls file*
file1.txt file2.txt file3.txt
$patlist file*
file1.txt
That is for some reason patlist script lists only the first file the matches
the pattern and not all the files.
I am using Debian Etch
$/bin/bash --version
/bin/bash --version
GNU bash, version 3.1.17(1)-release (i486-pc-linux-gnu)
Copyright (C) 2005 Free Software Foundation, Inc.
raju
--
Kamaraju S Kusumanchi
http://www.people.cornell.edu/pages/kk288/
http://malayamaarutham.blogspot.com/
Reply to: