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
Reading and Writing from Excel using Unix scripting AshishK UNIX and Linux Applications 3 11-08-2007 10:49 PM
reading/ writing to sockets rein Shell Programming and Scripting 1 09-20-2007 05:57 PM
Reading and Writing file on LAN lucky001 High Level Programming 3 03-30-2007 11:16 AM
What files are writing to a directory hattorihanzo UNIX for Dummies Questions & Answers 3 01-17-2006 08:00 AM
Reading and writing SCO DAT tapes uing Linux cstovall UNIX for Dummies Questions & Answers 3 04-27-2003 04:59 PM

Reply
 
Submit Tools LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 08-29-2006
Registered User
 

Join Date: Aug 2006
Posts: 2
Reading and Writing Files ?

Hello,
Our group is just starting to get into UNIX here. We are former REXX users on a VM Mainframe. Can someone point me to the documentation to read a file and write a file in a Unix Shell Script or does this have to be done in another language?
Thank you in advance...
Dave
Reply With Quote
Forum Sponsor
  #2 (permalink)  
Old 08-29-2006
reborg's Avatar
Administrator
 
Join Date: Mar 2005
Location: Ireland
Posts: 3,513
The answer depends (to some extent) on what you want to do.

Do you need sequential or random access to the file?
Reply With Quote
  #3 (permalink)  
Old 08-30-2006
Registered User
 

Join Date: Aug 2006
Posts: 2
Reading and writing files

Hello,
Yes it would be sequential. Read a record from a file and write to another file.
Thank you...
...Dave
Reply With Quote
  #4 (permalink)  
Old 08-30-2006
blowtorch's Avatar
Supporter
 
Join Date: Dec 2004
Location: Singapore
Posts: 2,325
A simple way to read lines from one file, do some processing and write to another is this:
Code:
while read line; do
   # do some processing on variable $line, maybe hold the result in another variable
   echo $variable_holding_result >> output_file # the variable may be $line
done < input_file
If you need help with the scripting, go here.

Last edited by blowtorch; 08-30-2006 at 07:25 AM. Reason: to add link
Reply With Quote
Google The UNIX and Linux Forums
Reply

Thread Tools
Display Modes




All times are GMT -7. The time now is 12:03 PM.


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 Global Fact Book

Content Relevant URLs by vBSEO 3.2.0