Get Compressed byte offset from .gz file


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Get Compressed byte offset from .gz file
# 1  
Old 04-18-2012
Get Compressed byte offset from .gz file

Hi ,

I have a .gz file whose contents look like below.
data1^filename1
data2^filename2.
..
.
.

Is it possible to find out the byte offset of each record from the .gz file.

Like in an uncompressed file.
grep -nb "Filename" give the byte offset of the record in this case.

Thanks,
Chetan.C
# 2  
Old 04-18-2012
This leaves the compressed file as is:
Code:
gzcat x.dat.gz|grep -nb "filename"

# 3  
Old 04-19-2012
Thanks Gary.
But what i want to know is the compressed byte offset.

Example:
Record1:
Compressed byte offset:0
Record2:
Compressed byte offset=Compressed byte length(Record1).

Something like this.Is this possible.?

Thanks,
Chetan.C
# 4  
Old 04-19-2012
Oh, sorry, no idea. I am interested to know why you want to know this though.
# 5  
Old 04-19-2012
Bumping up posts or double posting is not permitted in these forums.

Please read the rules, which you agreed to when you registered, if you have not already done so.

You may receive an infraction for this. If so, don't worry, just try to follow the rules more carefully. The infraction will expire in the near future

Thank You.

The UNIX and Linux Forums.

(original was here)
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

File name offset

Dear all, I want to offset the file numbers. can you please make some awk code or linux code for the same. Example: input file names ANI_WFMASS_PIST00001.gif ANI_WFMASS_PIST00002.gif . . . ANI_WFMASS_PIST0000n.gif offset --> 30 ANI_WFMASS_PIST00031.gif ANI_WFMASS_PIST00032.gif... (14 Replies)
Discussion started by: kri321shna
14 Replies

2. UNIX for Advanced & Expert Users

Grep --byte-offset not returning the offset (Grep version 2.5.1)

Hi, I am trying to get the position of a repeated string in a line using grep -b -o "pattern" In my server I am using GNU grep version 2.14 and the code is working fine. However when I am deploying the same code in a different server which is using GNU grep version 2.5.1 the code is not... (3 Replies)
Discussion started by: Subhamoy
3 Replies

3. Shell Programming and Scripting

compressed file

i have a file 4d7a94d0.bbb.1292 when i do file 4d7a94d0.bbb.1292 the ouput is below 4d7a94d0.bbb.1292: gzip compressed data - deflate method and i run this command gunzip -c 4d7a94d0.bbb.1292 | awk '{gsub("\"","")}/I_ACCOUNT_ID/{print $2}' RS=":|;" FS="," i get... (3 Replies)
Discussion started by: blackzinga80
3 Replies

4. Shell Programming and Scripting

Moving bytes in file by offset and length

Hi, I'm looking for a way (other than C) to pull out a number of bytes in a Linux file for a giving length. for example: file1 contains 2 records: abcdefghijkl mnopqrstuv ..... so, I want to pull starting in byte 9 for a length of 8 file2 would contain: ijkmnopq Thanks (2 Replies)
Discussion started by: jbt828
2 Replies

5. Shell Programming and Scripting

increment a value at an offset in hundreds very large hex file

I have a lot of very large hex files that I need to change one value at the same offset and save to another file. I have a script that finds each file and just need to put an operator for each file. I think sed might be able to do this but I have not used it before and would like some help. If... (8 Replies)
Discussion started by: Eruditass
8 Replies

6. UNIX for Dummies Questions & Answers

compressed file

I compressed a file by using gzip command gzip <<xx>> filename changed to xx.gz How to view this xx.gz file. Any idea. Thanks in advance. (7 Replies)
Discussion started by: venkatesht
7 Replies

7. Shell Programming and Scripting

Remove a byte(Last byte from the last line)

Hi All Can anyone please suggest me how to remove the last byte from a falt file .This is from the last line's last BYTE. Please suggest me something. Thank's and regards Vinay (1 Reply)
Discussion started by: vinayrao
1 Replies

8. Shell Programming and Scripting

Check if 2 files are identical byte-to-byte?

In my server migration requirement, I need to compare if one file on old server is exactly the same as the corresponding file on the new server. For diff and comm, the inputs need to be sorted. But I do not want to disturb the content of the file and need to find byte-to-byte match. Please... (4 Replies)
Discussion started by: krishmaths
4 Replies

9. UNIX for Dummies Questions & Answers

Reading a file from a specified offset

Hi, I want to read a file from a specified offset from the start of file. With the read command, is it possible to do so. Please suggest. Is there any other alternative? Thanks, Saurabh (2 Replies)
Discussion started by: saurabhsinha23
2 Replies

10. UNIX for Advanced & Expert Users

Script to Extract the line from File with specified offset

Hi All, I need to extract only XML details from large log file which may contain other unwanted junk details. For example, our xml will be start as <OUTBOUND_MESSAGE .....> and ends with </OUTBOUND_MESSAGE>. I want to extract only lines between these start and end tag (Including these tags)... (5 Replies)
Discussion started by: thinakarmani
5 Replies
Login or Register to Ask a Question