# using variable

**URL:** <https://community.unix.com/t/using-variable/169055>\
**Category:** Shell Programming and Scripting\
**Created:** [February 12, 2007, 12:32pm UTC](https://community.unix.com/t/using-variable/169055 "2007-02-12T12:32:22Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![shary](https://community.unix.com/letter_avatar/shary/32/5_5575768a8748004e209b776fc1b2916d.png) [@shary](https://community.unix.com/u/shary)\
**Post date:** [February 12, 2007, 12:32pm UTC](https://community.unix.com/t/using-variable/169055/1 "2007-02-12T12:32:22Z")

</div>

Dear Experts,

please can any body tell me that how to store tha value of this command in to a variable and after storing i have to display it  
command is:  
#sed -n '$p'

note: the value will come in numeric

Regards,  
SHARY

---

<div class="post-metadata">

**Author:** ![ahmedwaseem2000](https://community.unix.com/letter_avatar/ahmedwaseem2000/32/5_5575768a8748004e209b776fc1b2916d.png) [@ahmedwaseem2000](https://community.unix.com/u/ahmedwaseem2000)\
**Post date:** [February 12, 2007, 1:34pm UTC](https://community.unix.com/t/using-variable/169055/2 "2007-02-12T13:34:15Z")

</div>

you could store the result in a file like

sed -n '$p' source filename\>target filename  
cat target filename

or

Variable=`sed -n '$p' source filename`  
echo $Variable

if the above doesnt work try this

Variable=`eval sed -n '$p' source filename`  
echo $Variable

---

<div class="post-metadata">

**Author:** ![shary](https://community.unix.com/letter_avatar/shary/32/5_5575768a8748004e209b776fc1b2916d.png) [@shary](https://community.unix.com/u/shary)\
**Post date:** [February 13, 2007, 7:10am UTC](https://community.unix.com/t/using-variable/169055/3 "2007-02-13T07:10:09Z")

</div>

Dear Ahmed

thank you so much it really works.

regards,  
shary
