- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- unset positional parameter in shell
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
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
09-27-2011 01:46 AM
09-27-2011 01:46 AM
hello,
how can i unset positional parameter ?
unset a defined variable using the unset command:
unset variable_name
unset positional parameter ?
my proposal ? :
while [ $# -gt 0 ]
do
shift
done
test:
set a b c
$ echo "$*"
abc
#positional parameters $1, $2,$3
while [ $# -gt 0 ]
do
shift
done
echo "$*"
$
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-27-2011 02:22 AM
09-27-2011 02:22 AM
SolutionYour while-loop proposal can be simplified to:
shift $#
If you use the "set" command to set positional parameters, you should use "set -- <positional parameters>" to make sure you don't accidentally change any shell options.
An alternative way to unset all positional parameters would be:
set --
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-27-2011 01:43 PM
09-27-2011 01:43 PM
Re: unset positional parameter in shell
Typically you just use shift to march through your parms. You can use "set -A" to copy the parms to an array and then you can fiddle with that array. (Provided there are only 1023 parms.)
And then another "set -A" to restore the changed parms.
set -A SAVEARGS -- "$@"
The proper way to reset them is:
set -- "${SAVEARGS[@]}"
http://h30499.www3.hp.com/t5/Languages-and-Scripting/Shift-command/m-p/4133193