LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (http://www.linuxquestions.org/questions/linux-software-2/)
-   -   How to get variable from text file into Bash variable (http://www.linuxquestions.org/questions/linux-software-2/how-to-get-variable-from-text-file-into-bash-variable-731984/)

mcdef 06-10-2009 01:03 PM

How to get variable from text file into Bash variable
 
i have a text file i that has a mailTo: NAME in it. In a bash script i need to extract NAME and put it in a $variable to use. How do i do this?

harsshal 06-10-2009 01:13 PM

Code:

variable=`grep mailTo | cut -d ":" -f 2`
echo $variable


ramram29 06-10-2009 01:15 PM

#!/bin/sh

. mailTofile.txt

echo $variable


All times are GMT -5. The time now is 01:17 PM.