LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
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 10-30-2010, 04:29 PM   #1
dimpu
LQ Newbie
 
Registered: Sep 2010
Posts: 7

Rep: Reputation: 0
Exclamation Compressed file


Friends,

I want to know if there is anyway I can extract the first few contents of a zipped file and then the next fixed and so on?

For example, suppose I have a zipped file containing 1000000 natural numbers and I want to extract the first thousand numbers and then the next thousand numbers (1001-2000) and so on till I reach the end. Is this possible?

Thanks
 
Old 10-30-2010, 05:22 PM   #2
estabroo
Senior Member
 
Registered: Jun 2008
Distribution: debian, ubuntu, sidux
Posts: 1,117
Blog Entries: 2

Rep: Reputation: 113Reputation: 113
It should be possible, the deflate algorithm either uses a pre-built tree or builds it on the fly as it decodes, so no extra knowledge beyond that is needed to uncompress on the fly. You might not find a utility that'll do that directly but in linux you should be able to stream the output to your programs input doing something like zcat file.zip | your_program
 
Old 10-31-2010, 01:03 AM   #3
dimpu
LQ Newbie
 
Registered: Sep 2010
Posts: 7

Original Poster
Rep: Reputation: 0
Exclamation

Thanks you for your response but I don't wan't to feed that to any program instead I want to save the data in independent files, if possible.

The other thing I could do is use something like head -100 (for zipped files probably zcat), to get the first 100 values and feed it to the program and then consider data values from 101-200 and feed it. I am good with either way but don't really know if that's possible.

Thanks
 
Old 10-31-2010, 09:04 AM   #4
estabroo
Senior Member
 
Registered: Jun 2008
Distribution: debian, ubuntu, sidux
Posts: 1,117
Blog Entries: 2

Rep: Reputation: 113Reputation: 113
Code:
zcat nums.zip | perl -e '$start = shift @ARGV; $stop = (shift @ARGV) + $start; while (<>) { $i++; last if $i>=$stop; print if $i >= $start;}' 10 20
 
  


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
encrypting a compressed file? patcheezy AIX 1 06-11-2009 12:54 AM
Redirecting output to a compressed file rrosnowski Linux - Software 3 06-13-2007 07:51 AM
Compressed file system? General Linux - Software 2 03-16-2007 11:35 PM
Import using compressed file malru AIX 1 06-28-2006 05:42 AM
Missing Compressed file system in 2.6 Geeky_Kid Linux - General 3 12-23-2003 06:58 AM


All times are GMT -5. The time now is 05:05 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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration