- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: shell script help
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
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
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
07-06-2011 12:17 PM
07-06-2011 12:17 PM
Re: shell script help
Hi:
No matter which script you like ( and we'll use Dennis's since you reference his ), consider learning a Unix philosophy that says do-one-thing-and-do-it-well.
The whole script could be:
# cat mymax
#/usr/bin/sh
typeset ca=$1
typeset pa=$2
if (( ca > pa )); then
echo $ca
else
echo $pa
fi
...which then could be run to output to your terminal:
# ./mymax 100 99
100
...or to a file:
# ./mymax 100 99 > myoutput
...or to email:
# ./mymax 100 99 | mailx -s "Max Value" mymailaddress
The point is to allow the user to determine where he/she wants the output to appear rather than hard-coding that assumption into your script.
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-06-2011 09:17 PM
07-06-2011 09:17 PM
Re: shell script help
Hi dennis,
if the values are equal , how to print the value.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-06-2011 10:43 PM
07-06-2011 10:43 PM
Re: shell script help
thanks for your reply. i want to learn shell script .please send any pdf document or ppt
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-06-2011 11:07 PM
07-06-2011 11:07 PM
Re: shell script help
>if the values are equal, how to print the value.
Is this a new question?
Otherwise my script fragment will print the maximum of the two and always prints, even if equal.
If you only want to print if they are equal:
if (( ca == pa )); then
echo $ca
fi
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-07-2011 07:05 AM
07-07-2011 07:05 AM
Re: shell script help
@1a wrote:
thanks for your reply. i want to learn shell script .please send any pdf document or ppt
I used to recommend the "HP-UX Shell User's Guide" which was a nice overview of the various shells. With the advent of the "improved" (NOT!) HP websites, this doesn't appear to be available anymore.
Regardless, there are any number of good books on shell scripting. Find one for beginners and begin. I urge you to confine your initial learning to the Korn ('ksh') or Bash ('bash') shell rather than the dysfunctional C shell. In HP-UX, the default shell is simply called 'sh' and is a Korn variant. Bash can also be installed on HP-UX though it is usually the standard for most Linux distributions.
Part of learning to write code (in any language) is *writing* and *reading*. A very good collection of shell scripts is available here:
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-09-2011 12:13 AM
07-09-2011 12:13 AM
Re: shell script help
I only have a pretty old copy of the shell user's guide but it's still a pretty good one.
Find it attached.
hth,
Stephan
- « Previous
-
- 1
- 2
- Next »