- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: Range of positional parameters
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
07-18-2000 10:30 AM
07-18-2000 10:30 AM
I want to set a variable based on a range of positional parameters instead of using:
VARIABLE="${2} ${3} ${4} ${5} ${6} ${7}"
So that the VARIABLE looks like:
echo $VARIABLE
one two three four five...
I do not know up front how many positional parameters are being passed to my script and that is why I need to use a range.
Thanks in advance!
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-18-2000 10:35 AM
07-18-2000 10:35 AM
SolutionIf you want to skip a number of positional parameters, use 'shift' or 'shift n' to skip n positional parameters.
To assign the values of the other (remaining) positional parameters to one variable, do
VAR="$*"
This assigns all remaining positional parameters to VAR (separated by spaces)
Hope this helps,
Rik
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-18-2000 11:05 AM
07-18-2000 11:05 AM
Re: Range of positional parameters
POS_PARAM_1="${1}"
shift
ALL_OTHER_PARAMS="${*}"
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-18-2000 05:51 PM
07-18-2000 05:51 PM
Re: Range of positional parameters
#!/usr/dt/bin/dtksh
var=${@:2} # all the positional parameters after the first
var=${@:2:4} # the four positional parameters starting with the second
the syntax is ${@:offset:length}
if length is not specified or greater then the number of parameters, the remaining parameters are used.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-19-2000 03:16 AM
07-19-2000 03:16 AM
Re: Range of positional parameters
Tony
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-19-2000 03:19 AM
07-19-2000 03:19 AM
Re: Range of positional parameters
ms="command"
set -hk $ms; nn= `echo $#`; n=1
while [ $n -le $nn ]
do
me=command
ls -l $me
n=`expr $n+1`
shift 1
done