LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
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.

Notices


Reply
  Search this Thread
Old 06-10-2009, 01:03 PM   #1
mcdef
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
harsshal
Member
 
Registered: Jul 2006
Location: New York, NY
Distribution: redhat,ubuntu,RHEL,fedora,centOS
Posts: 105

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

Rep: Reputation: 47
#!/bin/sh

. mailTofile.txt

echo $variable
 
  


Reply



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

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 11:45 PM.

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