![]() |
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 |
| UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !! |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| environment variables | radhika03 | Shell Programming and Scripting | 3 | 01-22-2007 01:58 PM |
| environment variables | sumsin | High Level Programming | 6 | 03-13-2006 11:17 AM |
| help..Environment variables... | sekar sundaram | UNIX for Dummies Questions & Answers | 3 | 08-30-2005 03:35 AM |
| environment variables | Esaia | High Level Programming | 2 | 02-20-2003 08:19 PM |
| what is the use of Environment variables | indianguru | UNIX for Dummies Questions & Answers | 2 | 07-24-2001 09:41 PM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
||||
|
how to expand environment variables in a file?
I am new to unix and would appreciate if someone could help.
I have an environment variable SourceFilePath=/db1/Src/test set on the unix server. I want to expand this SHELL variable in a file using any command sed, awk etc File contents is as follows: var=$SourceFilePath/file.txt The command should create a new file by subsituting the environment variable with the actual value. The output should look like this. var=/db1/Src/test/file.txt |
|
||||
|
I think you mean to 'get the value of' a variable or maybe dereference it.
Do you mean you want to create a file using a variable as a filename? Code:
SourceFilePath=/db1/Src/test
var=${SourceFilePath}/file.txt
> $var # this creates an empty file named /db1/Src/test/file.txt
|
|
||||
|
Hi Jim,
I want to substitute the value for ${SourceFilePath} and not create a file with the variable name. file.txt is already existing. My scenario is like this. file.txt is present on the TEST & DEV I want to use the environment variable to point either to TEST or DEV. So i will have one parameter file PATH=$SourceFilePath/file.txt I want to write a script which will generate a new file for the following system TEST server should create a new file abc.txt with the following content PATH=/db1/Src/test/file.txt DEV server should create a new file xyx.txt with the following content PATH=/db1/Src/dev/file.txt The command or script must only substitute the value for the environment variable. Thanks for your input. |
| Sponsored Links | ||
|
|