LinuxQuestions.org
Visit the LQ Articles and Editorials section
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices

Reply
 
LinkBack Search this Thread
Old 07-27-2005, 10:57 AM   #1
yussef
Member
 
Registered: Sep 2004
Location: St Andrews, United Kingdom
Distribution: Ubuntu Breezy 5.10
Posts: 31

Rep: Reputation: 15
[Shell] Read a File from script


I know it is possible to read from a file using the awk command,
but can I read a config file and put each result in a different variable of
my script.

Code:
email=user@domain
subject=subject-here
Meaning that the email and subject will be in 2 different variables.
If someone could show me...

Thank you
 
Old 07-27-2005, 11:14 AM   #2
Matir
Moderator
 
Registered: Nov 2004
Location: San Jose, CA
Distribution: Ubuntu
Posts: 8,506

Rep: Reputation: 116Reputation: 116
Code:
. FILE_ABOVE
echo $email
echo $subject
 
Old 07-27-2005, 11:18 AM   #3
yussef
Member
 
Registered: Sep 2004
Location: St Andrews, United Kingdom
Distribution: Ubuntu Breezy 5.10
Posts: 31

Original Poster
Rep: Reputation: 15
thanks Matir but could you be a bit more explicit?

Thanks for your answer though
 
Old 07-27-2005, 11:32 AM   #4
Matir
Moderator
 
Registered: Nov 2004
Location: San Jose, CA
Distribution: Ubuntu
Posts: 8,506

Rep: Reputation: 116Reputation: 116
If the file is composed of name=value pairs, you can just source it and access the name as a variable of type $name.
 
Old 08-19-2008, 04:26 AM   #5
lostjohnny
Member
 
Registered: May 2006
Distribution: Fedora Core 6
Posts: 37

Rep: Reputation: 15
Quote:
Originally Posted by Matir View Post
If the file is composed of name=value pairs, you can just source it and access the name as a variable of type $name.
This is brilliant. I was trying for hours yesterday to find a solution to the same problem (reading a config file) and all I have to do is source the config file!

If there was a "slapping one's own forehead" smilie, I'd use it just here.

Graham
 
  


Reply


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
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
bash shell script read file line by line. Darren[UoW] Programming 51 07-04-2013 08:16 PM
shell script that read each line separatly xpucto Programming 6 09-20-2005 08:06 AM
Serial Port read in shell script tjt Linux - Newbie 1 08-12-2004 09:18 AM
Shell script to read from csv file hendemeg Programming 1 05-11-2004 08:23 PM
How to read ans parse MS word file using a Linux Shell script. Alek Linux - General 2 11-10-2003 02:07 PM


All times are GMT -5. The time now is 02:04 AM.

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration