HPE GreenLake Administration
- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Get differences between files and removing oldest ...
Operating System - HP-UX
1835346
Members
3131
Online
110078
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
04-13-2005 03:26 AM
04-13-2005 03:26 AM
Get differences between files and removing oldest if different
Hi. I need some help, I have a job which generates reports on a regular basis, what I need to do is loop through the files and compare each one with the newest one and if identical I would like to remove the older version. There will be an unknown number of files. Here is an example listing
/pfile/init_dba18_15491713042005.ora newest
/pfile/init_dba18_15320613042005.ora
/pfile/init_dba18_15251313042005.ora
/pfile/init_dba18_15191313042005.ora
I would like to remove the files with no changes and only keep the newest of the unchanged ones.
Thanks... Dave
/pfile/init_dba18_15491713042005.ora newest
/pfile/init_dba18_15320613042005.ora
/pfile/init_dba18_15251313042005.ora
/pfile/init_dba18_15191313042005.ora
I would like to remove the files with no changes and only keep the newest of the unchanged ones.
Thanks... Dave
why do i do this to myself
3 REPLIES 3
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-13-2005 03:31 AM
04-13-2005 03:31 AM
Re: Get differences between files and removing oldest if different
I would suggest the diff command.
diffs=$(diff file1 file2 | wc -l)
You will need a loop to process all the files.
if [ $diffs -ge 1 ]
then
rm file2
fi
Its a start.
SEP
diffs=$(diff file1 file2 | wc -l)
You will need a loop to process all the files.
if [ $diffs -ge 1 ]
then
rm file2
fi
Its a start.
SEP
Steven E Protter
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-13-2005 03:31 AM
04-13-2005 03:31 AM
Re: Get differences between files and removing oldest if different
Dave,
use ls -lt to get the files in creation order
Use the first (newest file) with head and do a diff aginst the next file (second newest).
If the result is no diff then rm the second file, repeat until all files are done.
Regards
use ls -lt to get the files in creation order
Use the first (newest file) with head and do a diff aginst the next file (second newest).
If the result is no diff then rm the second file, repeat until all files are done.
Regards
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-13-2005 03:31 AM
04-13-2005 03:31 AM
Re: Get differences between files and removing oldest if different
Dave,
use ls -lt to get the files in creation order
Use the first (newest file) with head and do a diff aginst the next file (second newest).
If the result is diff then rm the second file, repeat until all files are done.
Regards
use ls -lt to get the files in creation order
Use the first (newest file) with head and do a diff aginst the next file (second newest).
If the result is diff then rm the second file, repeat until all files are done.
Regards
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