LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   using DD to pull records out of a data file (https://www.linuxquestions.org/questions/linux-newbie-8/using-dd-to-pull-records-out-of-a-data-file-294432/)

fhinkle 02-24-2005 02:42 PM

using DD to pull records out of a data file
 
I there any way to use DD to pull the last 500 records? without knowing how many records total there are, and simply subtracting 500 from that and saying skip (that number)??

Tinkster 02-24-2005 02:56 PM

Nope ... dd references everything from the beginning
of file. But if the records are lines (\n - separated) you
could use tail -n 500


Cheers,
Tink

fhinkle 02-24-2005 03:28 PM

thats what i thought....

figured it couldn't hurt to ask...

and of course it wouldn't be so easy that the records were all on new lines,

I am working on getting a math expression down for it now...

Tinkster 02-24-2005 03:49 PM

Well ... if it has SOME sort of designated delimiter you
could always pipe it through awk and run tail against
its output ...


Cheers,
Tink

fhinkle 02-24-2005 03:56 PM

i guess i should explain what i am doing a little more

I am taking a file with ebcdic data in it, and trying to take the first 500 reords, convert them to ascii, then output to a file. and the same for the last 500 records to a different file. I haven't been informed of a delimiter of any kind, I was just told to go by byte length for the records. I guess this is the reason they want me using DD.

Tinkster 02-24-2005 04:10 PM

Oh, I see :)

So they have a fixed record length? In that case getting
the last 500 mathematically is trivial, neh? :)

And I agree, considering the EBCDIC/ASCII conversion
dd would be the best tool for the job :)


Cheers,
Tink

fhinkle 02-24-2005 04:20 PM

yeah, I got it all done now... I was just trying to avoid using math if i could. :)

thanks for the help :)


All times are GMT -5. The time now is 09:03 AM.