Re: seek within a large file

From: Alan Connor (zzzzzz_at_xxx.yyy)
Date: 10/17/03

  • Next message: Jimmy Zhang: "Re: seek within a large file"
    Date: Fri, 17 Oct 2003 06:29:07 GMT
    
    

    On Fri, 17 Oct 2003 06:50:47 +0100, Andy Baxter <news3@earthsong.null.free-online.co.uk> wrote:
    >
    >
    > On Fri, 17 Oct 2003 04:59:07 +0000, Alan Connor wrote:
    >
    >> On Fri, 17 Oct 2003 04:48:29 +0100, Andy Baxter <news3@earthsong.null.free-online.co.uk> wrote:
    >>>
    >>>>
    >>>> I can't help but point out that while he is following your advice,
    >>>> he could already have read the file.
    >>>>
    >>>> I'd probably cut it into pieces first with split, deleting the original
    >>>> file, then cat it back together afterwards.
    >>>>
    >>>> You can do whatever way you want, but it would be cool if you would actually
    >>>> post a *practical* approach to doing what he wants, rather than just some
    >>>> vague geek-talk....
    >>>
    >>> If he only wanted to do this once from the command line, your solution
    >>> might work but would be very inefficient. It would probably be
    >>> better to do something like:
    >>>
    >>> dd if=bigfile of=samplefile bs=1024 skip=1048576 count=samplesize
    >>>
    >>
    >> That's IT! I *knew* there was a quick way to do that right, without writing
    >> a new utility.
    >>
    >>
    >>> But from reading the original question, I don't think that's what he was
    >>> looking for - sounds more like he's writing a program which needs to be
    >>> run more than once and hence should be reasonably efficient.
    >>>
    >>> andy.
    >>>
    >>
    >> And is yours not? Seems like using it in a script with read to get the
    >> variables would work nicely.
    >>
    >> Is there, Andy, a utility that converts kb decimal to kb binary? Or just
    >> any number to whatever its not in at present, hex/octal/dec?
    >
    > Have a look at man printf and man 3 printf.
    >
    > You can convert (unsigned) decimal to octal with
    >
    > printf '%o' decimal-number
    >

    didn't get anything but printf '' 20
    when I tried that with 20

    > printf doesn't do binary, but you could convert octal to binary in a shell
    > script using some kind of look up table - e.g. a file like:
    >
    > 0 000
    > 1 001
    > 2 010
    > 3 011
    > 4 100
    > 5 101
    > 6 110
    > 7 111
    >
    > andy.
    >
    > --
    > remove 'n-u-l-l' to email me. html mail or attachments will go in the spam
    > bin unless notified with [html] or [attachment] in the subject line.

    So where did you get skip=1048576 then? How did you convert 1GB to that?

    The way I get them when it seems like a script needs the 'binary-kb', is
    to copy a file that's close to that size, add and subtract lines until
    ls -sh reads, say, 16mb, and then run just ls -l on it .... Sure seems
    like the long way around the barn....

    -- 
    Alan C
    

  • Next message: Jimmy Zhang: "Re: seek within a large file"

    Relevant Pages

    • Re: seek within a large file
      ... > Have a look at man printf and man 3 printf. ... > printf '%o' decimal-number ... The way I get them when it seems like a script needs the 'binary-kb', ...
      (comp.os.linux.misc)
    • Re: Extending fluxbox menu with a script.
      ... Scott Ferguson wrote: ... I can only check the script works, can't check if mmaker likes it. ... printf will. ...
      (Debian-User)
    • problem with readline
      ... I have a script that queries a database, grabs a bunch of email addresses from ... push @email_list, $address; ...
      (perl.beginners)
    • Re: configure an awk program from file?
      ... Strip the script down to make it clearer: ... printf "\tAufwendungen:\n" ... You can re-write that with condition-action syntax as: ... You can force the "else" implementation with condition-action syntax by using a "next": ...
      (comp.lang.awk)
    • Re: random problem with 8.3 from yesterday
      ... # This script format a thumb drive connected to USB as da0. ... printf "You have to run this script as 'root' to succeed.\n" ... The whole point of labeling the file system is ...
      (freebsd-stable)