Visit Jeremy's Blog.
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, 01: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, 01: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, 01: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 03:08 AM
text formatting in bash variable David the H. Programming 10 05-09-2008 12:02 PM
Getting a variable from a text-file (bash) PatrickBecks Programming 4 02-14-2008 08:52 PM
Bash read in variable length text records lynx81191 Programming 4 11-17-2007 08:53 PM
Bash store last line from displayed text output in a variable carl0ski Programming 1 01-16-2007 03:38 AM > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 04:14 PM.

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
Open Source Consulting | Domain Registration