Solved

AIX 6.1, setting env vars

Posted on 2011-09-21
4
545 Views
Last Modified: 2013-11-17
I am trying to set an env var in AIX

I set the variable TEST, but it does not show up as being set

$ echo $TEST

$ set TEST=one
$
$ set
AUTHSTATE=files
........
_=TEST=one
$
$ echo $TEST

$ echo $PATH
/opt/IBM/mqsi/7.0/jre16/bin:/opt/IBM/mqsi/7.0/bin:/usr/bin:/etc:/usr/sbin:/usr/ucb:/var/mqm/bin:/usr/bin/X11:/sbin:.

Open in new window


What does this line mean:

_=TEST=one

Open in new window


What am I doing wrong?

Thanks
0
Comment
Question by:Los Angeles1
  • 3
4 Comments
 
LVL 68

Accepted Solution

by:
woolmilkporc earned 500 total points
ID: 36575462
Hi,

the variable "_"  indicates the value of the parameter of the last set command issued.

It doesn't have any meaning for the actual environment (in a user's perspective).

Explanation: set is meant  to set positional parameters.

set TEST=one

will set the positional variable $1 to "TEST=one" (and $_, for that matter).

Check this with "echo $1"  and also "echo $_"

A special case is "set" when issued without any arguments. This displays the names and values of all KornShell variables, sorted by name.

Don't use "set" for defining variables.

Use just

VAR=value

for the current shell and

export VAR=value

for the current shell and its subshells (e.g. scripts called from the current shell).


wmp
0
 
LVL 68

Expert Comment

by:woolmilkporc
ID: 36575500
Try this to make it (perhaps) a bit clearer:


set A B C

echo $1
echo $2
echo $3

echo $_

OK?


0
 

Author Closing Comment

by:Los Angeles1
ID: 36575567
Thanks, that was perfect.  Everything is working great, and I seet the $1, etc
0
 
LVL 68

Expert Comment

by:woolmilkporc
ID: 36575577
>> doesn't have any meaning ... <<

It depends.

A net trick is using $_ to find the last field in a line.

Assume that you want to know the value of the 15 minute load average:

set $(uptime); echo $_

Not very common, but ...
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Suggested Solutions

Let's say you need to move the data of a file system from one partition to another. This generally involves dismounting the file system, backing it up to tapes, and restoring it to a new partition. You may also copy the file system from one place to…
Installing FreeBSD… FreeBSD is a darling of an operating system. The stability and usability make it a clear choice for servers and desktops (for the cunning). Savvy?  The Ports collection makes available every popular FOSS application and packag…
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
In a previous video, we went over how to export a DynamoDB table into Amazon S3.  In this video, we show how to load the export from S3 into a DynamoDB table.

708 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now