- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- ksh, 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
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
06-14-2007 12:19 AM
06-14-2007 12:19 AM
PF=/rd/opsys/${1:-editor}.pf
I have a file called /rd/opsys/editor.pf, and I know in the script I'm looking at, it should resolve to PF=/rd/opsys/editor.pf.
So what is 1:-
It would seem 1 refers to the first parameter that is passed to the script, for if I pass one, it shows up in the value of PF.
I'm guessing this means: if parameter 1 is set, take it's value, else use "editor"
Am I off the mark?
Fred
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-14-2007 12:25 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-14-2007 12:58 AM
06-14-2007 12:58 AM
Re: ksh, script help
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-14-2007 08:20 AM
06-14-2007 08:20 AM
Re: ksh, script help
COLUMNS=${COLUMNS:-80}
You can even use this construct in a calculation:
let ROWS=${ROWS:-24}-2
So ROWS is now set to 2 less than actual or default value. In your example, 1 is shorthand for the first parameter passed to the current shell.
Bill Hassell, sysadmin
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-15-2007 12:03 AM
06-15-2007 12:03 AM
Re: ksh, script help
It's worth mentioning that this form of parameter substitution:
${parameter:-word}
will return 'word' if 'parameter' is unset and/or null, but WILL NOT set 'parameter' to the value of 'word'. While this form:
${parameter:=word}
WILL set 'parameter' to the value of 'word' if 'parameter' is unset and/or null.
In your particular example, you must use the first form, as the shell does not allow positional parameters (in your case: '$1') to be set after the fact.
PCS
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-15-2007 12:09 AM
06-15-2007 12:09 AM