LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 09-08-2004, 06:31 AM   #1
suchi_s
Member
 
Registered: May 2004
Posts: 133

Rep: Reputation: 15
code to read block from the file


read similar blocks from a file
whose first line contains "occupancy"
and last line also contains "block"
in shell scripting
 
Old 09-08-2004, 06:35 AM   #2
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 7.7 (?), Centos 8.1
Posts: 17,954

Rep: Reputation: 2634Reputation: 2634Reputation: 2634Reputation: 2634Reputation: 2634Reputation: 2634Reputation: 2634Reputation: 2634Reputation: 2634Reputation: 2634Reputation: 2634
more details/example needed....
 
Old 09-08-2004, 06:41 AM   #3
suchi_s
Member
 
Registered: May 2004
Posts: 133

Original Poster
Rep: Reputation: 15
INPUT FILED
DJKD
DEJKFL
OCCUPANCY OF DATA
EIUR
REJR
EJR
END OF REPORT
HFJDF
FKDFJ
OCCUPANCY OF DATA
DJEKFO
FRJFT
ERKJ
FREOK
END OF REPORT

HOW TO EXTRACT BLOCKS AND PUT IN ANOTHER FILE
 
Old 09-08-2004, 06:48 AM   #4
druuna
LQ Veteran
 
Registered: Sep 2003
Posts: 10,532
Blog Entries: 7

Rep: Reputation: 2401Reputation: 2401Reputation: 2401Reputation: 2401Reputation: 2401Reputation: 2401Reputation: 2401Reputation: 2401Reputation: 2401Reputation: 2401Reputation: 2401
This should work:

sed -n '/OCCUPANCY/,/REPORT/p'

Hope this helps.
 
Old 09-08-2004, 07:06 AM   #5
suchi_s
Member
 
Registered: May 2004
Posts: 133

Original Poster
Rep: Reputation: 15
this is solved for constant file size
what if the file size is increasing after every second and at times half of the block is come at particular instant and rest is coming in next interval..
how to track the file and the blocks
 
Old 09-08-2004, 07:21 AM   #6
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 7.7 (?), Centos 8.1
Posts: 17,954

Rep: Reputation: 2634Reputation: 2634Reputation: 2634Reputation: 2634Reputation: 2634Reputation: 2634Reputation: 2634Reputation: 2634Reputation: 2634Reputation: 2634Reputation: 2634
If I understand you correctly, you want to read data blocks from a file that is still open and being written to ....
If you can't wait until it is finished and closed, I think it will be very difficult if not impossible to do in shell.
On the other hand, here is a solution in Perl: http://iis1.cps.unizar.es/Oreilly/pe...ok/ch08_06.htm
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
block of code suchi_s Programming 2 12-10-2004 04:40 PM
reiserfsck and cannot read block solex Linux - General 6 09-03-2004 06:52 PM
Why The block driver I wrote can't read? freasy Programming 2 07-17-2004 07:50 AM
Bad switch statement (problem in the code block?) nifflerX Linux - General 2 07-14-2004 04:45 PM
how to format a HD that has the block 0 impossible to read ? ordx Linux - Hardware 2 12-10-2003 11:39 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 03:08 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration