LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices

Reply
 
Search this Thread
Old 02-24-2005, 02:42 PM   #1
fhinkle
LQ Newbie
 
Registered: Feb 2005
Location: Waldorf, MD
Distribution: Red Hat Enterprise/SuSe Linux
Posts: 6

Rep: Reputation: 0
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)??

Last edited by fhinkle; 02-24-2005 at 02:43 PM.
 
Old 02-24-2005, 02:56 PM   #2
Tinkster
Moderator
 
Registered: Apr 2002
Location: in a fallen world
Distribution: slackware by choice, others too :} ... android.
Posts: 22,978
Blog Entries: 11

Rep: Reputation: 879Reputation: 879Reputation: 879Reputation: 879Reputation: 879Reputation: 879Reputation: 879
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
 
Old 02-24-2005, 03:28 PM   #3
fhinkle
LQ Newbie
 
Registered: Feb 2005
Location: Waldorf, MD
Distribution: Red Hat Enterprise/SuSe Linux
Posts: 6

Original Poster
Rep: Reputation: 0
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...
 
Old 02-24-2005, 03:49 PM   #4
Tinkster
Moderator
 
Registered: Apr 2002
Location: in a fallen world
Distribution: slackware by choice, others too :} ... android.
Posts: 22,978
Blog Entries: 11

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


Cheers,
Tink
 
Old 02-24-2005, 03:56 PM   #5
fhinkle
LQ Newbie
 
Registered: Feb 2005
Location: Waldorf, MD
Distribution: Red Hat Enterprise/SuSe Linux
Posts: 6

Original Poster
Rep: Reputation: 0
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.
 
Old 02-24-2005, 04:10 PM   #6
Tinkster
Moderator
 
Registered: Apr 2002
Location: in a fallen world
Distribution: slackware by choice, others too :} ... android.
Posts: 22,978
Blog Entries: 11

Rep: Reputation: 879Reputation: 879Reputation: 879Reputation: 879Reputation: 879Reputation: 879Reputation: 879
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
 
Old 02-24-2005, 04:20 PM   #7
fhinkle
LQ Newbie
 
Registered: Feb 2005
Location: Waldorf, MD
Distribution: Red Hat Enterprise/SuSe Linux
Posts: 6

Original Poster
Rep: Reputation: 0
yeah, I got it all done now... I was just trying to avoid using math if i could.

thanks for the help
 
  


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
c++ append data to file blizunt7 Programming 3 07-04-2005 12:47 AM
File says it's data, so what do I do with it? dlublink Linux - General 2 03-15-2005 05:56 PM
echo data in to a file xlord Linux - Newbie 3 05-29-2004 12:19 PM
reading data from a file afrm Programming 2 12-16-2003 07:43 PM
Can i pull the card out? nutshell Linux - General 2 03-14-2002 06:59 PM


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

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration