![]() |
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 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 |
| What wrong with the variable definition | dsravan | Shell Programming and Scripting | 1 | 09-15-2006 10:57 AM |
| define length of variable | cbarker | UNIX for Dummies Questions & Answers | 10 | 04-01-2005 12:42 PM |
| Using Grep to Define a Variable | cspcspcsp | UNIX for Dummies Questions & Answers | 1 | 10-12-2001 12:22 PM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
||||
|
How to define a variable with variable definition is stored in a variable?
Hi all,
I have a variable say var1 (output from somewhere, which I can't change)which store something like this: echo $var1 name=fred age=25 address="123 abc" password=pass1234 how can I make the variable $name, $age, $address and $password contain the info? I mean do this in a simple way rather than for line in $var1 do varname=`echo $line | cut -f 1 -d '='` varvalue=`echo $line | cut -f 2 -d '='` eval $varname=$varvalue done I am looking for something like . $var1 #I know it is wrong and then... echo $name # fred echo $age # 25 echo $address # 123 abc echo $password #pass1234 I cannot cat $var1 > tmpfile . tmpfile rm tmpfile because the var1 contain sensitive info e.g. password Thanks a lot! Last edited by freddy1228; 1 Week Ago at 04:34 AM.. Reason: cannot delete |
|
||||
|
Code:
eval $var1 |
| Sponsored Links | ||
|
|
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|