The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

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

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 08-29-2006
tracydp tracydp is offline
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
  #2 (permalink)  
Old 08-29-2006
reborg's Avatar
reborg reborg is offline Forum Staff  
Administrator
  
 

Join Date: Mar 2005
Location: Ireland
Posts: 4,206
The answer depends (to some extent) on what you want to do.

Do you need sequential or random access to the file?
  #3 (permalink)  
Old 08-30-2006
tracydp tracydp is offline
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
  #4 (permalink)  
Old 08-30-2006
blowtorch's Avatar
blowtorch blowtorch is offline Forum Advisor  
Supporter
  
 

Join Date: Dec 2004
Location: Singapore
Posts: 2,350
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 10:25 AM.. Reason: to add link
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

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




All times are GMT -4. The time now is 03:21 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0