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 > 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 09:57 PM
Opening output file while still in process monkfan UNIX for Dummies Questions & Answers 4 03-02-2006 04:35 AM
store output to a file and read from it afadaghi Shell Programming and Scripting 2 10-04-2005 12:00 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 10-05-2008
Lorna Lorna is offline
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
  #2 (permalink)  
Old 10-05-2008
danmero danmero is offline Forum Advisor  
  
 

Join Date: Nov 2007
Location: 45.48-73.63
Posts: 1,419
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.
  #3 (permalink)  
Old 10-06-2008
Lorna Lorna is offline
Registered User
  
 

Join Date: Oct 2008
Posts: 13
Thank you so much, that's very helpful!!
  #4 (permalink)  
Old 10-06-2008
matrixmadhan matrixmadhan is offline Forum Advisor  
Technorati Master
  
 

Join Date: Mar 2005
Location: leaf node in B+ tree
Posts: 2,944
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
Sponsored Links
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 08:19 AM.


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