Re: Any Idea (..Continuing)
- From: "John L" <jl@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Thu, 1 Dec 2005 13:45:29 -0000
<pankaj_wolfhunter@xxxxxxxxxxx> wrote in message news:1133440473.049591.3980@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
> we have two files:
>
> File 1
>
>
> 000130|ascii|exp.001.0.1313/
> 000130|script|exp.001.1313.1817/
> 000140|ascii|db2exp.001.3130.1316/
>
>
> File 2
> Some large data
>
> The end part of File1 i.e exp.001.0.1313, exp.001.1313.1817 etc
> specifies the byte position for the respective data in File2.
> Means that in the first line of File1 (i.e exp.001.0.1313) 0 specifies
> the starting byte position and 1313 specifies the ending byte position
> in File 2 and so goes on with all the lines.
>
> I want to write a script which takes File 1 into loop, takes the first
> line, then takes the respective byte positions.
> Extract out that much data out of File 2 and replaces that data with
> the last word of the line just fetched from File 1.
> Similarly for the next line and so on.
>
> I hope I have made myself clear. Any Ideas?
>
I do not have time to do this for you but my first thought is
to use dd (with bs=1, count and seek set to appropriate values)
and to do it in two stages.
Step 1: parse the data and output write a script that uses dd.
Step 2: run the script output by stage 1.
My second thought is to use perl rather than dd, and read
the whole of file 2 so you can treat it as an array which
should make seeking and replacement easier. But still to do
this in two stages as above. (Or use C and memory-map file2:
it is conceptually the same thing.) And maybe in this case
the two stages could be two different perl functions within
the same program: again, conceptually it is much the same.
--
John.
.
- References:
- Any Idea (..Continuing)
- From: pankaj_wolfhunter
- Any Idea (..Continuing)
- Prev by Date: Re: Unix Scripting Command "&"
- Next by Date: Re: sed: appending line to end of file
- Previous by thread: Any Idea (..Continuing)
- Next by thread: Re: Any Idea (..Continuing)
- Index(es):
Relevant Pages
|