The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
Google UNIX.COM


UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !!

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
[C++] File I/O (Reading from a Random-Access File) VersEtreOuNe High Level Programming 0 02-12-2008 01:34 PM
reading from a file and pass as variables and ignore # in the file konark Shell Programming and Scripting 4 11-08-2007 12:55 AM
Reading a file and writing the file name to a param file. thebeginer UNIX for Advanced & Expert Users 1 10-05-2007 01:38 PM
Reading file names from a file and executing the relative file from shell script anushilrai Shell Programming and Scripting 4 03-10-2006 02:25 AM
Reading specific contents from a file and appending it to another file dnicky Shell Programming and Scripting 5 10-04-2005 02:45 AM

Reply
 
Submit Tools LinkBack Thread Tools Search this Thread Display Modes
  #1  
Old 08-14-2006
Registered User
 

Join Date: Mar 2006
Posts: 55
reading a file into a varable...

Hi all,

I have had a hunt round the net (and the forum (more importantly)) but carn't just see anything that helps. Does anyone care to put me out of my missery and tell me how to read a file into a variable?

thanks,

B14... aka... Marky Mark...
Reply With Quote
Forum Sponsor
  #2  
Old 08-14-2006
Registered User
 

Join Date: Aug 2006
Posts: 69
try this....

var="`cat file`"

But what do you want to achive through this??

regards
Apoorva kumar
Reply With Quote
  #3  
Old 08-14-2006
Registered User
 

Join Date: Mar 2006
Posts: 55
well its pretty simple really to be honest. I have a couple of SQL scripts that output some numbers to file, I just want to read them into my script so that I can compare them.

Thanks I will try this out,

Mark.
Reply With Quote
  #4  
Old 08-14-2006
blowtorch's Avatar
Supporter
 
Join Date: Dec 2004
Location: Singapore
Posts: 2,328
You want to read the entire file into a single variable? At one shot? Dunno if you can do that and keep it readable by anything else... To read the file a line at a time, you can see this thread.
Reply With Quote
  #5  
Old 08-14-2006
Registered User
 

Join Date: Mar 2006
Posts: 55
Wink

Well the above does work (under Solaris 5.8) but you see, the files that I am reading are only contain 1 set of numbers (eg could be 1, it could be 14,0954) so I just wanted to read them into a variable and use the numbers in another script.

Thanks for the replies though,

Mark.
Reply With Quote
Google The UNIX and Linux Forums
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes




All times are GMT -7. The time now is 12:04 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008. All Rights Reserved.Ad Management by RedTyger Visit The Complex Event Processing Blog

Content Relevant URLs by vBSEO 3.2.0