07-03-2010
An "export" statement only works in the current shell or subshell and makes a variable available to any scripts you call. It does not make the variable available to the parent shell. In this case the "export" statement is surplus in both examples. I can't explain in this context why "while" created a subshell when "for" did not.
cfajohnson may know better.
10 More Discussions You Might Find Interesting
1. UNIX for Advanced & Expert Users
How do I export a directory ?
I am trying to link the directory from another machine. (2 Replies)
Discussion started by: brv
2 Replies
2. UNIX for Dummies Questions & Answers
how do I export my display from my unix box to my pc
basically what is the syntax for export DISPLAY (2 Replies)
Discussion started by: csaunders
2 Replies
3. Windows & DOS: Issues & Discussions
My friend's boss has asked me to help update a customer database. They have a limited amount of space and have asked if I can do this from my home computer.
She is working on a Unix system with a program called Accuterm. My understanding is that this program is a dedicated program for the... (0 Replies)
Discussion started by: clearchoice
0 Replies
4. Shell Programming and Scripting
Hi,
I am exporting the environment variable from config file, but when I echo the variable it does not display any value. Here is the snippet of the code
#!/bin/sh
export ENVIRONMENT_ROOT_DIRECTORY="/cb/$ENVIRONMENT"
echo $ENVIRONMENT_ROOT_DIRECTORY
${JAVA_HOME}/bin/java... (2 Replies)
Discussion started by: bhavnabakshi
2 Replies
5. Shell Programming and Scripting
Here's how;
Say;
I have a variable VAR which contains something like MY_DIR=/apphome/some/mydir.
What I want is I want to export VAR so that it will vitually export MY_DIR. Please suggest me? (15 Replies)
Discussion started by: swmk
15 Replies
6. Shell Programming and Scripting
Can someone help me out to export awk output to excel file in different rows? Plzzzz its urgent...:( (4 Replies)
Discussion started by: goutam_igate
4 Replies
7. Solaris
Hi,
can anyone tell me the difference between the below two examples:
Eg-1:
# name=bravo
# echo $bravo
what would be the o/p
Eg-2:
# name1=jhonny
# export name1
# echo $name1
what would be the o/p
If the o/p's of both examples are the same then what is the use of the cmd export... (3 Replies)
Discussion started by: rahul_11d
3 Replies
8. Shell Programming and Scripting
Even though the idea "might" not be great I still wrote this piece of code to get practice.. Which means that it is the CODE that matters here.
Anyways;
The intension is to create a program(or do we call it script?) that searches recursively through a folder to find a file - stored in a... (4 Replies)
Discussion started by: Pesk
4 Replies
9. Shell Programming and Scripting
I have a txt file from which i am assiging a value to a variable
using the code in script1
script1.sh
export f=$(sed -n "/Freq *=/ s/.*= *//p" ${R_path}/output.txt)
echo "$f" --------> this works
in script2 ( which executes the script1)
eval ./script1.sh
if && ; then
echo... (1 Reply)
Discussion started by: shashi792
1 Replies
10. Shell Programming and Scripting
I am experimenting with some scripting as a way to learn more about it. I have a simple script that calls two other scripts. Each script echos some stuff to prove it ran and then sets a simple variable and exports it.
I cannot get one of the variables to display back in the main calling script... (2 Replies)
Discussion started by: scottrif
2 Replies
EXPORT(P) POSIX Programmer's Manual EXPORT(P)
NAME
export - set the export attribute for variables
SYNOPSIS
export name[=word]...
export -p
DESCRIPTION
The shell shall give the export attribute to the variables corresponding to the specified names, which shall cause them to be in the envi-
ronment of subsequently executed commands. If the name of a variable is followed by = word, then the value of that variable shall be set to
word.
The export special built-in shall support the Base Definitions volume of IEEE Std 1003.1-2001, Section 12.2, Utility Syntax Guidelines.
When -p is specified, export shall write to the standard output the names and values of all exported variables, in the following format:
"export %s=%s
", <name>, <value>
if name is set, and:
"export %s
", <name>
if name is unset.
The shell shall format the output, including the proper use of quoting, so that it is suitable for reinput to the shell as commands that
achieve the same exporting results, except:
1. Read-only variables with values cannot be reset.
2. Variables that were unset at the time they were output need not be reset to the unset state if a value is assigned to the variable
between the time the state was saved and the time at which the saved output is reinput to the shell.
When no arguments are given, the results are unspecified.
OPTIONS
See the DESCRIPTION.
OPERANDS
See the DESCRIPTION.
STDIN
Not used.
INPUT FILES
None.
ENVIRONMENT VARIABLES
None.
ASYNCHRONOUS EVENTS
Default.
STDOUT
See the DESCRIPTION.
STDERR
The standard error shall be used only for diagnostic messages.
OUTPUT FILES
None.
EXTENDED DESCRIPTION
None.
EXIT STATUS
Zero.
CONSEQUENCES OF ERRORS
Default.
The following sections are informative.
APPLICATION USAGE
None.
EXAMPLES
Export PWD and HOME variables:
export PWD HOME
Set and export the PATH variable:
export PATH=/local/bin:$PATH
Save and restore all exported variables:
export -p > temp-fileunset a lot of variables... processing. temp-file
RATIONALE
Some historical shells use the no-argument case as the functional equivalent of what is required here with -p. This feature was left
unspecified because it is not historical practice in all shells, and some scripts may rely on the now-unspecified results on their imple-
mentations. Attempts to specify the -p output as the default case were unsuccessful in achieving consensus. The -p option was added to
allow portable access to the values that can be saved and then later restored using; for example, a dot script.
FUTURE DIRECTIONS
None.
SEE ALSO
Special Built-In Utilities
COPYRIGHT
Portions of this text are reprinted and reproduced in electronic form from IEEE Std 1003.1, 2003 Edition, Standard for Information Technol-
ogy -- Portable Operating System Interface (POSIX), The Open Group Base Specifications Issue 6, Copyright (C) 2001-2003 by the Institute of
Electrical and Electronics Engineers, Inc and The Open Group. In the event of any discrepancy between this version and the original IEEE
and The Open Group Standard, the original IEEE and The Open Group Standard is the referee document. The original Standard can be obtained
online at http://www.opengroup.org/unix/online.html .
IEEE
/The Open Group 2003 EXPORT(P)