![]() |
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| 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 |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
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? |
|
||||
|
Quote:
Code:
cat file | while read row; do .... done >> file |
|
||||
|
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.. |
|
||||
|
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 |
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|