# Replace variable with its value while printing

**URL:** <https://community.unix.com/t/replace-variable-with-its-value-while-printing/264830>\
**Category:** Shell Programming and Scripting\
**Created:** [April 29, 2010, 2:22am UTC](https://community.unix.com/t/replace-variable-with-its-value-while-printing/264830 "2010-04-29T02:22:49Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![dashing201](https://community.unix.com/user_avatar/community.unix.com/dashing201/32/5589_2.png) [@dashing201](https://community.unix.com/u/dashing201)\
**Post date:** [April 29, 2010, 2:22am UTC](https://community.unix.com/t/replace-variable-with-its-value-while-printing/264830/1 "2010-04-29T02:22:49Z")

</div>

Hi  
I have a file in which there is list of files.  
eg:

$path1/file1  
$path1/file2  
$path2/file3

I am trying to read this file in other script.However the value of variable i.e. $path1 and $path2 is not replaced by its value.  
How to do it ?

I am trying:

```nohighlight
 
while read line
do
echo $line 
done<$InputFile>Temp2.tmp

```

$path1 and $path2 are global variables

---

<div class="post-metadata">

**Author:** ![agn](https://community.unix.com/letter_avatar/agn/32/5_5575768a8748004e209b776fc1b2916d.png) [@agn](https://community.unix.com/u/agn)\
**Post date:** [April 29, 2010, 2:29am UTC](https://community.unix.com/t/replace-variable-with-its-value-while-printing/264830/2 "2010-04-29T02:29:40Z")

</div>

Try,

```nohighlight
while read line
do
eval echo $line 
done<$InputFile>Temp2.tmp

```

---

<div class="post-metadata">

**Author:** ![dashing201](https://community.unix.com/user_avatar/community.unix.com/dashing201/32/5589_2.png) [@dashing201](https://community.unix.com/u/dashing201)\
**Post date:** [April 29, 2010, 3:11am UTC](https://community.unix.com/t/replace-variable-with-its-value-while-printing/264830/3 "2010-04-29T03:11:05Z")

</div>

Thnks man ! :b:  
Its workin gr8 for me...🙂

I m just lovin UNIX as so big things can be done by so small commands :D;)
