[zcat] [gunzip -c] header


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting [zcat] [gunzip -c] header
# 1  
Old 04-25-2013
[zcat] [gunzip -c] header

Hello,

When i lauches this command
Code:
ssh -n server_name gunzip -c "/REP/xxxx.gz" > server.log

There are a few stray characters like NULNULNULNUL100644 NUL000000NUL000000NUL00024002704 12135060747 012607NUL at the beginning of server.log.
In the xxxx.gz there is a tar file
I'm not sure but it seems this is the TAR's header.
Can you help me to remedy that ?

Thank you

Last edited by amazigh42; 04-25-2013 at 10:43 AM..
# 2  
Old 04-25-2013
We need to know the name of the file inside it. This should list the filenames it contains.

Code:
ssh -n server_name tar -ztf "/REP/xxxx.gz"

# 3  
Old 05-14-2013
Hello,
Sorry for my late reply, I just returned from vacation.

Inside there is one or several tar's files.

Code:
gunzip xxxx.gz

Code:
ll
xxxx.tar

Thank you

---------- Post updated at 10:39 AM ---------- Previous update was at 03:28 AM ----------

To be clearer, take any file
For example server.log
Then pass the following commands
Code:
tar -czvf new_file.tar.gz server.log

Code:
gunzip -c new_file.tar.gz >my_file

Code:
head my_file

Now you can see few stray characters at the header

My question is how to redirect a file without header ?
Thank you in advance for your help.
.
# 4  
Old 05-14-2013
You have a tar file there. There is a header because it is not a log file, it is a tar file.

If you want to extract the file from the tar, use tar to extract it. You have to give tar the file name.

Code:
tar -zxf "/REP/xxxx.gz" server.log

That should extract server.log from it.
# 5  
Old 05-15-2013
Hello,

I have to deal with several archives in different servers, it is quite restrictive.
It forces me to decompress and compress the file again because it is an archive directory. Is there a simpler solution with gunzip or remove the header with grep or something ?

Thanks you.
# 6  
Old 05-15-2013
To extract a tar file, one is supposed to use tar...

This does not force you to do so locally. You could retrieve the file first, or even stream it into tar.

Code:
ssh username@host cat /path/to/file | tar -zxf - filename

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Find header in a text file and prepend it to all lines until another header is found

I've been struggling with this one for quite a while and cannot seem to find a solution for this find/replace scenario. Perhaps I'm getting rusty. I have a file that contains a number of metrics (exactly 3 fields per line) from a few appliances that are collected in parallel. To identify the... (3 Replies)
Discussion started by: verdepollo
3 Replies

2. Solaris

ZCAT xxx.Z|tar -xvf - decompression slow ?

I have recently built a new server and patched Soalris 10 up tp latest bundle etc... When I run a decompress using the format zcat fred.Z |tar -xvf - it runs at a very slow rate. A similiar server which is less powerful runs over twice as quick. Is there any work arounds to configure decompress... (4 Replies)
Discussion started by: smcart
4 Replies

3. Shell Programming and Scripting

awk & zcat not working together

I have a tar file which i want to read and check some specific fields basis on which i want to get output. Code zcat samplefile.tar.gz | awk 'FNR==1 {++counter} counter ==2 {BB=1;next} substr($0,26,2) =="01") {next} (substr($0,28,12) ~ "^") {next} (substr($0,184,3) in BB) {next} 1 '... (7 Replies)
Discussion started by: siramitsharma
7 Replies

4. UNIX for Dummies Questions & Answers

How zcat works?

Hi, just i would like to know, how will be the response if you try to read a 40GB compressed file using zcat. a)Uncompress the 40GB file and have it in the disk. use cat to view the steps. b)Use zcat directly to view the compressed file? What are the steps being occurred in step (b)? Where... (3 Replies)
Discussion started by: pandeesh
3 Replies

5. Shell Programming and Scripting

BASH ZCAT EGREP Shell Script

I created a backup script that emails all the admins when the backup is complete and attaches a log file of what what backed up. On occasion, something happens in which the backups stop working, I started "grep"ing around /var/log/syslog and I usually find the smoking gun. My goal is to zcat... (8 Replies)
Discussion started by: metallica1973
8 Replies

6. Shell Programming and Scripting

zcat two files

Hi, Like cat file1 file2 > file Can I do zcat file1.gz file2.gz > file.gz (11 Replies)
Discussion started by: jacobs.smith
11 Replies

7. UNIX for Dummies Questions & Answers

Merge all csv files in one folder considering only 1 header row and ignoring header of all others

Friends, I need help with the following in UNIX. Merge all csv files in one folder considering only 1 header row and ignoring header of all other files. FYI - All files are in same format and contains same headers. Thank you (4 Replies)
Discussion started by: Shiny_Roy
4 Replies

8. Linux

zcat on Linux

Hi I am trying to extract a <filename>.tar.Z on a SLES machine using zcat. The command I am using is zcat <filename>.tar.Z | tar xf - When I use the above I get the following message tar: Read 7168 bytes from - I think the message is benign because I see that my files where... (2 Replies)
Discussion started by: felixmat1
2 Replies

9. Linux

Reading the header of a tar file(posix header)

say i have these many file in a directory named exam. 1)/exam/newfolder/link.txt. 2)/exam/newfolder1/ and i create a tar say exam.tar well the problem is, when i read the tar file i dont find any metadata about the directories,as you cannot create a tar containig empty directories. on the... (2 Replies)
Discussion started by: Tanvirk
2 Replies

10. UNIX for Dummies Questions & Answers

zcat --> Arg list too long

Hi all I have more than 1000 files in a folder and when ever i use a "compress" or "zcat" command it give error /bin/zcat: Arg list too long. . any solution for this :o (3 Replies)
Discussion started by: muneebr
3 Replies
Login or Register to Ask a Question