comparing the name of the file

hi,

i have to check the name of file in other directory which contains number of files to check for duplicte file name avaliable or not.

thanks

ls -1 /dir1/* > file1
ls -1 /otherdir1/* > file2
awk ' { FILENAME=="file1" { arr[$0]++}
      { FILENAME=="file2" { if($0 in arr) {print $0}' file1 file2

cat all the files of a different directories and pipe those to different files and do a compare on that .. for example...

$cat /home/dir1 >file1 # file 1 contains all the files in dir1
$cat /home/dir2 > file2 # file 2 contains all the files in dir2
$cmp file1 file2 # compare

or simply

$find path -name filename # path is the path of the directory and filename is the name of the file u want to find