LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
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
  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
LQ Guru
 
Registered: Nov 2004
Location: San Jose, CA
Distribution: Debian, Arch
Posts: 8,507

Rep: Reputation: 128Reputation: 128
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
LQ Guru
 
Registered: Nov 2004
Location: San Jose, CA
Distribution: Debian, Arch
Posts: 8,507

Rep: Reputation: 128Reputation: 128
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



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
bash shell script read file line by line. Darren[UoW] Programming 57 04-17-2016 06:07 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

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 09:38 AM.

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