![]() |
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| how to unset maxuprc in solarsi zones | kalpeer | SUN Solaris | 1 | 06-15-2009 10:46 AM |
| How do I define a particular dir in PATH variable and then unset that dir | Hangman2 | Shell Programming and Scripting | 2 | 01-06-2009 12:14 AM |
| how to unset the readonly variable | Nidhi2177 | UNIX for Advanced & Expert Users | 2 | 09-12-2007 05:35 AM |
| How to unset 'finger' info? | Chanakya.m | Shell Programming and Scripting | 3 | 01-23-2006 09:12 AM |
| Is there any way to set env variable in top level Makefile and unset when done | umen | Shell Programming and Scripting | 0 | 10-23-2005 08:15 AM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
|||||
|
The following function 'gsunset', deletes the variables specified by an RE :
Code:
gunset()
{
local var_re="${1:-.*}"
eval $( set | \
awk -v FS='=' \
-v VAR="$var_re" \
'$1 ~ VAR { print "unset", $1 }' )
}
VAR1=value1
VAR2=value2
VAR3=value3
echo "Vars before gunset"
set | grep ^VAR
gunset 'VAR.*'
echo "Vars after gunset"
set | grep ^VAR
Code:
Vars before gunset VAR1=value1 VAR2=value2 VAR3=value3 Vars after gunset |
|
||||
|
Change your approach. NEVER use undeclared variables. There is an option "set -o nounset" if I remember correctly.
You should have something like this: Code:
#!/bin/env ksh typeset my_variable typeset all_my_variables_should_be_defined_like_that my_variable='abc' Last edited by vgersh99; 10-01-2009 at 04:48 PM.. Reason: code tags, PLEASE! |
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|