Visit the LQ Articles and Editorials section
Go Back > Forums > Linux Forums > Linux - Software
User Name
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.


  Search this Thread
Old 06-10-2009, 02:03 PM   #1
LQ Newbie
Registered: Jun 2009
Posts: 6

Rep: Reputation: 0
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?
Old 06-10-2009, 02:13 PM   #2
Registered: Jul 2006
Location: New York, NY
Distribution: redhat,ubuntu,RHEL,fedora,centOS
Posts: 105

Rep: Reputation: 15
variable=`grep mailTo | cut -d ":" -f 2`
echo $variable
Old 06-10-2009, 02:15 PM   #3
Registered: Jul 2003
Location: Miami, Florida, USA
Distribution: Debian
Posts: 848
Blog Entries: 1

Rep: Reputation: 47

. mailTofile.txt

echo $variable


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Problem with bash script - variable name within variable name steven.c.banks Linux - Newbie 3 03-10-2009 04:08 AM
text formatting in bash variable David the H. Programming 10 05-09-2008 01:02 PM
Getting a variable from a text-file (bash) PatrickBecks Programming 4 02-14-2008 09:52 PM
Bash read in variable length text records lynx81191 Programming 4 11-17-2007 09:53 PM
Bash store last line from displayed text output in a variable carl0ski Programming 1 01-16-2007 04:38 AM

All times are GMT -5. The time now is 06:48 AM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration