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
appending a file using sed in ksh smac Shell Programming and Scripting 3 01-02-2008 04:09 PM
Can't read floppy and cdrom in single user mode ajnabi SUN Solaris 2 03-21-2007 09:15 AM
Reading specific contents from a file and appending it to another file dnicky Shell Programming and Scripting 5 10-04-2005 06:45 AM
appending a file chumba UNIX for Dummies Questions & Answers 1 05-24-2001 12:09 PM
Appending out to a file Astudent UNIX for Dummies Questions & Answers 1 10-20-2000 03:17 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 02-25-2007
videsh77 videsh77 is offline
Registered User
  
 

Join Date: Aug 2004
Posts: 144
Appending file in the read mode.

I have situation, wherein while reading the file, I intend to write the same file & loop ahead until the end of file.

Problem I am facing is I can only read the file. Like ...

cat file | while read row; do
....
done


So if I write anything to this file within while block, is not read within this same while loop.

Is there any way, or construct so I can achieve Append the file during read process?
  #2 (permalink)  
Old 02-25-2007
ahmedwaseem2000 ahmedwaseem2000 is offline
Registered User
  
 

Join Date: Aug 2005
Location: Bangalore
Posts: 219
Quote:
Originally Posted by videsh77
I have situation, wherein while reading the file, I intend to write the same file & loop ahead until the end of file.

Problem I am facing is I can only read the file. Like ...

cat file | while read row; do
....
done


So if I write anything to this file within while block, is not read within this same while loop.

Is there any way, or construct so I can achieve Append the file during read process?

Code:
cat file | while read row; do
....
done >> file

  #3 (permalink)  
Old 02-26-2007
videsh77 videsh77 is offline
Registered User
  
 

Join Date: Aug 2004
Posts: 144
Say initially file has values like :

A
B

If I append the same file with values :
C
D

Then I expect it will loop A, B, C, & D values. Though it is appending to the same file, it is not looping values C & D.

It is something like in JAVA, you have data structure as vector. You can iterate & populate at the same time. So in iteration, you can as well iterate the recently added value.

Last edited by videsh77; 02-26-2007 at 02:53 AM..
  #4 (permalink)  
Old 02-26-2007
ahmedwaseem2000 ahmedwaseem2000 is offline
Registered User
  
 

Join Date: Aug 2005
Location: Bangalore
Posts: 219
this should iterate the recently added value. but make sure that you add a condition in the while loop to exit or else it might go to infinite loop. Might be you could add a counter variable to exit after running the loop for specific number of times.


Code:
while read fname ; do
echo x >>$filename
 done <$filename

  #5 (permalink)  
Old 02-26-2007
videsh77 videsh77 is offline
Registered User
  
 

Join Date: Aug 2004
Posts: 144
Great, seems working. Thanks Ahmed.
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 04:13 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