Hi Team ,
Is there a way I can check to see if the same file say , test.dat exists multiple times in the directory path ?
Please help.
Thanks
Megha
Hi Team ,
Is there a way I can check to see if the same file say , test.dat exists multiple times in the directory path ?
Please help.
Thanks
Megha
Try:
find /directory -type f -name test.dat
ls test.dat | wc -l
This will give you the count of occurances of the file.
If it returns zero then no file present.
That is useless because you can't have more than one file of the same name in the same folder. It will always be either zero, or one.
If you are looking for files with the same name and content then:
find . -type f -name test.dat -exec cksum {} +
HiCorona688
I do agree with you but I am developing a script that handles exceptions like these just in case.
Thanks everyone.
Megha