The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
How to read/process a .gz file, one line at a time? dayscripter Shell Programming and Scripting 2 10-16-2008 06:26 AM
Post Shell programming: Question about source a file and read data from the file ccwq Shell Programming and Scripting 3 08-04-2007 10:28 PM
read file and output message happyv Shell Programming and Scripting 12 01-24-2007 08:57 PM
Opening output file while still in process monkfan UNIX for Dummies Questions & Answers 4 03-02-2006 03:35 AM
store output to a file and read from it afadaghi Shell Programming and Scripting 2 10-04-2005 12:00 PM

Reply
 
Submit Tools LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 10-05-2008
Registered User
 

Join Date: Oct 2008
Posts: 13
Read from file > process > output to file

Hi all,

OK, I am totally new to shell scripting as I just started today. All I want from shell scripting is something very basic, and I've been searching for tutorials on "processing files" and I could not find a suitable one for my level.

I want to read two columns from a data file, one raw at a time, use these values as input to some program, then parse the output of that program (output is text) and append important info to another file

I am going insane about this, please help me find a useful tutorial!!!

Thanks
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 10-05-2008
danmero danmero is offline Forum Advisor  
 

Join Date: Nov 2007
Location: 45.48-73.63
Posts: 901
This is a very "first time question"
The basic concept should be:
Code:
while read col1 col2
do 
  echo $col1 >> output.file
  echo $col2 >> output.file
done < data.file
For solutions you can use the search tab on this forum... or Google for tutorials for your shell.
Reply With Quote
  #3 (permalink)  
Old 10-06-2008
Registered User
 

Join Date: Oct 2008
Posts: 13
Thank you so much, that's very helpful!!
Reply With Quote
  #4 (permalink)  
Old 10-06-2008
Technorati Master
 

Join Date: Mar 2005
Location: k-tier distributed caching
Posts: 2,803
Quote:
Originally Posted by danmero View Post
This is a very "first time question"
The basic concept should be:
Code:
while read col1 col2
do 
  echo $col1 >> output.file
  echo $col2 >> output.file
done < data.file
For solutions you can use the search tab on this forum... or Google for tutorials for your shell.
this is much better, no need to open and close files multiple times

Code:
while read col1 col2
do 
  echo $col1 
  echo $col2 
done < data.file >> output.file
Reply With Quote
Google The UNIX and Linux Forums
Reply

Bookmarks

Tags
None

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:




All times are GMT -4. The time now is 07:40 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
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

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66