- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Unix easy question: How do I do one IF evaluating...
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
09-26-2003 03:38 AM
09-26-2003 03:38 AM
I want to evalute in ksh two expressions into one IF statement:
** The problem there is in: elif below, How do I to compare $b1 -gt 20 and $dia -eq 3
Thanks...
b1=20
dia=3
#dia=`date "+ %u"`
echo $b1 > algo
echo $dia >> algo
if [ $b1 -gt 24 ]
then
elm -s "Important" bb@cr.com < $HOME/bin/Mensaje
cat $HOME/bin/Mensaje | mailx -s Respaldo ggonzalez@cr.freshdelmonte.com
#cp $HOME/bin/cero $HOME/bkdb/a1
elif ( $b -gt 19; $dia -eq 3 )
then
cat $HOME/bin/Mensaje | mailx -s Hi xx@yy
fi
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-26-2003 03:40 AM
09-26-2003 03:40 AM
Re: Unix easy question: How do I do one IF evaluating tow conditions
if [[ $b1 -gt 19 -a $dia -eq 3 ]] ; then
echo "it is true for both"
fi
HTH
-- Rod Hills
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-26-2003 03:46 AM
09-26-2003 03:46 AM
Re: Unix easy question: How do I do one IF evaluating tow conditions
(iNTERNAL TEST SYNTAX - faster, cheaper)
if [[ $b1 -gt 19 && $dia -eq 3 ]]
then
..
..
fi
(EXTERNAL TEST COMMAND SYNTAX)
if [ $b1 -gt 19 && $dia -eq 3 ]
then
..
..
fi
Now to be nit-picky you should really enclose any variables in {}'s
so
if [[ ${b1} -gt 19 && ${dia} -eq 3 ]]
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-26-2003 03:47 AM
09-26-2003 03:47 AM
Re: Unix easy question: How do I do one IF evaluating tow conditions
to be a newline. This would give you [ $b -gt 20 ] && [ $dia -eq 3 ] && {
mailx -s Hi xx@yy
}
The opposite of && is ||
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-26-2003 03:55 AM
09-26-2003 03:55 AM
Re: Unix easy question: How do I do one IF evaluating tow conditions
elif ( $b -gt 19 && $dia -eq 3 )
Good luck
Adam
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-26-2003 03:58 AM
09-26-2003 03:58 AM
Re: Unix easy question: How do I do one IF evaluating tow conditions
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-26-2003 04:01 AM
09-26-2003 04:01 AM
Re: Unix easy question: How do I do one IF evaluating tow conditions
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-26-2003 04:02 AM
09-26-2003 04:02 AM
Re: Unix easy question: How do I do one IF evaluating tow conditions
Should work.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-26-2003 04:11 AM
09-26-2003 04:11 AM
Re: Unix easy question: How do I do one IF evaluating tow conditions
This is not work: elif [ $b -gt 19 -a $diag -eq 3 ]
Bellow don't show any error message but don't do anything...
elif [[ ${b} -gt 19 && ${dia} -eq 3 ]]
then
cat $HOME/bin/Mensaje | mailx -s Respaldo ggon@cr.com
echo "hola"
echo "hola"
echo "hola"
fi
~
~
~
~
~
"CtrlDayToBk" 18 lines, 493 characters
[oracle8i@bandeco]/home/oracle8i/bin> CtrlDayToBk
[oracle8i@bandeco]/home/oracle8i/bin>
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-26-2003 04:13 AM
09-26-2003 04:13 AM
Re: Unix easy question: How do I do one IF evaluating tow conditions
Will it be the "then" below the elif?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-26-2003 04:28 AM
09-26-2003 04:28 AM
Re: Unix easy question: How do I do one IF evaluating tow conditions
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-26-2003 04:36 AM
09-26-2003 04:36 AM
Re: Unix easy question: How do I do one IF evaluating tow conditions
Any echo was showed
What's wrong here!!!!!???!!!
[oracle8i@bandeco]/home/oracle8i/bin> cat CtrlDayToBk
#b1=`cat $HOME/bkdb/a1`
b1=20
dia=3
#dia=`date "+ %u"`
echo $b1 > algo
echo $dia >> algo
if [ $b1 -gt 24 ]
then
echo " Primer IF"
elm -s "Importante" esandoval@cr.com < $HOME/bin/Mensaje
cat $HOME/bin/Mensaje | mailx -s Respaldo ggo@cr.com
#cp $HOME/bin/cero $HOME/bkdb/a1
elif [[ ${b} -gt 19 && ${dia} -eq 3 ]]
then
cat $HOME/bin/Mensaje | mailx -s Respaldo gg@cr.com
echo "hola"
echo "hola"
echo "hola"
fi
[oracle8i@bandeco]/home/oracle8i/bin> cat algo
20
3
[oracle8i@bandeco]/home/oracle8i/bin>
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-26-2003 04:40 AM
09-26-2003 04:40 AM
Solution$b seems to be 0 to me.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-26-2003 04:42 AM
09-26-2003 04:42 AM
Re: Unix easy question: How do I do one IF evaluating tow conditions
you set your variable as
b1
but in your elif you test for
b
regards,
John K.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-26-2003 04:44 AM
09-26-2003 04:44 AM
Re: Unix easy question: How do I do one IF evaluating tow conditions
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-26-2003 05:22 AM
09-26-2003 05:22 AM
Re: Unix easy question: How do I do one IF evaluating tow conditions
I miss the $b1...
Thanks to all... a lot, NOW it works fine..!!