- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: PATHETICALLY simple diff script question.
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
08-27-2004 01:40 AM
08-27-2004 01:40 AM
I have two files: A and B.
I would like a snippet of shell code.
if [ ??????? ] ; then
echo " the files are the same"
else
echo " the files are different"
fi
I don't need to know the exact differences, just that they ARE different.
steve
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-27-2004 01:49 AM
- Tags:
- md5sum
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-27-2004 01:53 AM
08-27-2004 01:53 AM
Re: PATHETICALLY simple diff script question.
or using diff
A=file1
B=file2
if [ "`diff $A $B`" = "" ]
then
echo "the files are the same"
else
echo " the files are different"
fi
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-27-2004 01:55 AM
08-27-2004 01:55 AM
Re: PATHETICALLY simple diff script question.
Steve
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-27-2004 01:55 AM
08-27-2004 01:55 AM
Re: PATHETICALLY simple diff script question.
The simplest case would be something like:
diff file1 file2 > /dev/null 2>&1
if [ $? -eq 0 ]
then
echo "the files are the same"
else
echo "the files are different"
fi
Of course, you'd probably want to first make sure "file1" and "file2" exist, and you'd also want the ksh program to take the file names as arguments. You could also call cksum against the two files and compare the output, but the above syntax should work for using diff against two files.
Regards,
Dave
I work at HPE
HPE Support Center offers support for your HPE services and products when and how you need it. Get started with HPE Support Center today.
[Any personal opinions expressed are mine, and not official statements on behalf of Hewlett Packard Enterprise]

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-27-2004 01:57 AM
08-27-2004 01:57 AM
Re: PATHETICALLY simple diff script question.
diff file1 file2 2>&1 >/dev/null
if [ $? -eq 0 ]; then
echo "The files are the same"
elif [ $? -eq 1 ]; then
echo "The files are different"
else
echo "There was an error"
fi
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-27-2004 01:58 AM
08-27-2004 01:58 AM
Re: PATHETICALLY simple diff script question.
Got lots of good answers. THANKS.