- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - Linux
- >
- Help in script
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
Discussions
Discussions
Forums
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
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
тАО03-01-2009 03:27 AM
тАО03-01-2009 03:27 AM
Hi ,
I need to compare ~ 200 files in 2 diffrent directories using cksum command . and get the diffrence files ....
10x
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-01-2009 03:50 AM
тАО03-01-2009 03:50 AM
Solution1.) create names for two temporary files
TMPFILE1=$(mktemp)
TMPFILE2=$(mktemp)
# make sure they will be auto-removed when the script terminates, even if there is an error
trap "rm -f $TMPFILE1 $TMPFILE2 2>/dev/null" EXIT
2.) run cksum on the files of the first directory, store the output to the first temporary file
3.) run cksum on the files of the second directory, store the output to the second temporary file
4.) run "diff" on the both temporary files to pick out the differences.
Questions:
Do you need to compare *all* the files in those directories? Or just a subset of ~200 files while the directories may have more than that?
If the latter, how can you get the list of filenames to compare? (Command line/wildcard expression, environment variable, file containing a list of filenames, something else?)
MK
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-01-2009 01:09 PM
тАО03-01-2009 01:09 PM
Re: Help in script
You may want to run comm(1) instead of diff.
You will have to put the names before the checksums:
cksum * | awk '{print $3, $1, $2}' > $TMPFILE1
Then: comm -3 $TMPFILE1 $TMPFILE2
Of course you could do a directory diff if both directories are available on the same machine.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-01-2009 02:43 PM
тАО03-01-2009 02:43 PM
Re: Help in script
Why? Have you considered "diff -q"?
> [...] and get the diffrence files ....
Do you mean a list of the names of the files
which differ, or a list of the differences?
What, exactly, would you like to see?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-02-2009 12:10 AM
тАО03-02-2009 12:10 AM