HPE GreenLake Administration
- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: dir comparison script help
Operating System - HP-UX
1833589
Members
4061
Online
110061
Solutions
Forums
Categories
Company
Local Language
back
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Discussions
Forums
Discussions
back
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Blogs
Information
Community
Resources
Community Language
Language
Forums
Blogs
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-18-2004 06:37 AM
12-18-2004 06:37 AM
dir comparison script help
I have two directories; dirA and dirB. Each contains very large number of ordinary files.
I wanted to find out the duplicate file name in each dir. If found, write the duplicate file name with full attributes to log and send out a notification to particular user/owner to remove the file from the dir.
example:
dirA
file1
file2
file3
dirB
file1
file4
file5
Can someone help me on this.
Thanks in advance
I wanted to find out the duplicate file name in each dir. If found, write the duplicate file name with full attributes to log and send out a notification to particular user/owner to remove the file from the dir.
example:
dirA
file1
file2
file3
dirB
file1
file4
file5
Can someone help me on this.
Thanks in advance
3 REPLIES 3
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-18-2004 06:50 AM
12-18-2004 06:50 AM
Re: dir comparison script help
Have a look at the dircmp command.
# man dircmp
for more information.
# man dircmp
for more information.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-21-2004 01:58 AM
12-21-2004 01:58 AM
Re: dir comparison script help
Or
# find dirA -type f -print | sort > filelistA
# find dirB -type f -print | sort > filelistB
# comm -3 filelistA filelistB > commonfiles
# find `cat commonfiles` -exec your_script {} \;
# find dirA -type f -print | sort > filelistA
# find dirB -type f -print | sort > filelistB
# comm -3 filelistA filelistB > commonfiles
# find `cat commonfiles` -exec your_script {} \;
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-21-2004 10:09 AM
12-21-2004 10:09 AM
Re: dir comparison script help
In Unix, there are any number of ways to do just about anything. Here's how I would approach your problem:
cd /dir1
for i in `ls -1`
do
if test -f dir2/$i
then
echo "$i is a duplicate"
ls -l dir2/$i >>/logfile
OWNER=`ls -l dir2/$i|awk '{print $3}`
STRING="$i is a duplicate file"
echo "$STRING"|mailx -s "$i is a duplicate" $OWNER@somewhere.com
fi
done
cd /dir1
for i in `ls -1`
do
if test -f dir2/$i
then
echo "$i is a duplicate"
ls -l dir2/$i >>/logfile
OWNER=`ls -l dir2/$i|awk '{print $3}`
STRING="$i is a duplicate file"
echo "$STRING"|mailx -s "$i is a duplicate" $OWNER@somewhere.com
fi
done
The opinions expressed above are the personal opinions of the authors, not of Hewlett Packard Enterprise. By using this site, you accept the Terms of Use and Rules of Participation.
Company
Events and news
Customer resources
© Copyright 2025 Hewlett Packard Enterprise Development LP