|
|||||||
| Forums | Search Forums | Register | Forum Rules | Man Pages | Albums | FAQ | Members | Calendar | Search | Today's Posts | Mark Forums Read |
| UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !! |
|
|
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
How to check if the same file exists multiple times?
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 |
| Sponsored Links | ||
|
|
#2
|
||||
|
||||
|
Try: Code:
find /directory -type f -name test.dat |
| Sponsored Links | ||
|
|
#3
|
|||
|
|||
|
Code:
ls test.dat | wc -l This will give you the count of occurances of the file. If it returns zero then no file present. |
|
#4
|
|||
|
|||
|
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.
|
| Sponsored Links | |
|
|
#5
|
|||
|
|||
|
If you are looking for files with the same name and content then: Code:
find . -type f -name test.dat -exec cksum {} + |
| Sponsored Links | |
|
|
#6
|
|||
|
|||
|
HiCorona688
I do agree with you but I am developing a script that handles exceptions like these just in case. Thanks everyone. Megha |
| Sponsored Links | ||
|
![]() |
| Thread Tools | Search this Thread |
| Display Modes | |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| File exists, but cannot be opened.How to check- whether it could be opened to read when it exists | rxg | Shell Programming and Scripting | 2 | 05-10-2012 02:15 PM |
| Check to see if a file exists? | buechler66 | Shell Programming and Scripting | 5 | 06-28-2011 10:38 PM |
| check a file is exists in multiple tar file? | k_manimuthu | Shell Programming and Scripting | 7 | 03-03-2011 12:27 AM |
| Check if file exists + ulp :S | ruben.rodrigues | Programming | 2 | 02-22-2010 02:28 AM |
| FTP check if file exists and log it | gseyforth | Shell Programming and Scripting | 1 | 08-12-2009 03:40 AM |
|
|