- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- comparing and deleting a files
Categories
Company
Local Language
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
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
Community
Resources
Forums
Blogs
- 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
04-03-2007 09:06 PM
04-03-2007 09:06 PM
comparing and deleting a files
I have 2 Directories a & b. I need to compare these 2 Directories if both directories containts same files dont delete a files if one of the directory containts extra files than delete that file.
using PERL script
Can anyone please help me do this.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-03-2007 09:12 PM
04-03-2007 09:12 PM
Re: comparing and deleting a files
and welcome to the forums !
In HPUX it would be a simple diff giving the directories ats parameters (seem "man diff").
In PERL I would look at:
http://search.cpan.org/~gavinc/File-DirCompare-0.02/DirCompare.pm
Please also read:
http://forums1.itrc.hp.com/service/forums/helptips.do?#33 on how to reward any useful answers given to your questions.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-03-2007 09:49 PM
04-03-2007 09:49 PM
Re: comparing and deleting a files
Comparing two directories is working fine, but now i wanted to delete a file which is not there in another directory....
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-03-2007 10:08 PM
04-03-2007 10:08 PM
Re: comparing and deleting a files
If you the diff command it will show files that are unique to each directory:
Only in test2: b.lis
Only in test: c.lis
So I would redirect the output of the diff and then grep on the directory you want to 'clean up'. In my example test2.
grep -e'Only in test2' diff.lis | awk -F':' '{print $2}'
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-03-2007 10:42 PM
04-03-2007 10:42 PM
Re: comparing and deleting a files
it showing fils perl/temp/a/test2 and perl/temp/test2/b/test2 are common and similar.
file unique only in
perl/temp/a/test1
i am understand that 2 paragraph wat u written.... i am new to perl.
i wanted to delete perl/temp/a/test1
from that directory..
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-03-2007 10:45 PM
04-03-2007 10:45 PM
Re: comparing and deleting a files
$ ls dir1 > dir1.out
$ ls dir2 > dir2.out
$ comm -23 dir1.out dir2.out # extra files in dir1
$ comm -13 dir1.out dir2.out # extra files in dir2
If you want to remove the extra files in dir1 and you have debugged this script:
$ rm -f $(comm -23 dir1.out dir2.out)
(This doesn't compare the content of the files, just names.)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-03-2007 10:48 PM
04-03-2007 10:48 PM
Re: comparing and deleting a files
i am writting this script in windows.....
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-03-2007 11:06 PM
04-03-2007 11:06 PM
Re: comparing and deleting a files
You are in a HP-UX forum so it is expected that you have a real shell: sh or ksh. If you want some perl help, you could ask under languages and scripting:
http://forums1.itrc.hp.com/service/forums/categoryhome.do?categoryId=150
You can ask the moderator to move it by replying to this thread:
http://forums1.itrc.hp.com/service/forums/questionanswer.do?threadId=1114353
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-03-2007 11:14 PM
04-03-2007 11:14 PM
Re: comparing and deleting a files
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-08-2007 07:40 AM
04-08-2007 07:40 AM
Re: comparing and deleting a files
There is a cute toy avaiable for free download from Microsoft which will do all you scripts might suggest to do and then some...
google: microsoft synctoy download
It will likely lead to:
http://www.microsoft.com/downloads/details.aspx?familyid=E0FC1154-C975-4814-9649-CCE41AF06EB7&displaylang=en
Hein.