- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- how to use "!" and "diff" command ?
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-07-2007 06:36 AM
04-07-2007 06:36 AM
how can i to use "!" with diff for the following command:
if ! diff $environment/vgp_$(hostname).txt ${LOG}/${A}_vgp.TEMP > ${LOG}/${A}_vgp.DIFFERENT
if i run above sentence, the result is:
01_bdf_filesystem.sh[40]: !: not found
for avoiding "else" ... i need to know it when it is different ...
Please let me know.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-07-2007 06:58 AM
04-07-2007 06:58 AM
SolutionThat's not legal Posix/KSH syntax. I suggest something like this:
# diff $environment/vgp_$(hostname).txt ${LOG}/${A}_vgp.TEMP > ${LOG}/${A}_vgp.DIFFERENT
# RETURN=$?
# if [ "${RETURN}" != 0 ]; then
> echo different
> else
> echo no_different
> fi
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-07-2007 07:05 AM
04-07-2007 07:05 AM
Re: how to use "!" and "diff" command ?
It worked ... thanks a lot !!!!!
:0)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-07-2007 07:07 AM
04-07-2007 07:07 AM
Re: how to use "!" and "diff" command ?
You can use it like this to see the difference between the two :
#########################################
diff $environment/vgp_$(hostname).txt ${LOG}/${A}_vgp.TEMP > ${LOG}/${A}_vgp.DIFFERENT
if [ -s ${LOG}/${A}_vgp.DIFFERENT ]
then
echo "Difference Found "
echo "" ; echo "Difference is : "
cat ${LOG}/${A}_vgp.DIFFERENT
else
echo "No Difference found! "
fi
##########################################
Cheers,
Raj.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-08-2007 01:47 PM
04-08-2007 01:47 PM
Re: how to use "!" and "diff" command ?
Actually ! script is legal in sh. I found this out last time it was asked.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-08-2007 11:30 PM
04-08-2007 11:30 PM
Re: how to use "!" and "diff" command ?
all Bourne-like shells allow this construct in using 'else':
if diff a b
then :
else
do_what_is-needed
fi
BTW, ksh93 (/usr/dt/bin/dtksh) permits the above 'if ! ' construct.
mfG Peter
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-09-2007 12:05 AM
04-09-2007 12:05 AM
Re: how to use "!" and "diff" command ?
Dennis > Actually ! script is legal in sh. I found this out last time it was asked.
...and so *I* have not learned, too. Thanks, Dennis * Peter.
Regards!
...JRF...