read file from tar.gz archive


 
Thread Tools Search this Thread
Top Forums Programming read file from tar.gz archive
# 1  
Old 03-10-2003
Question read file from tar.gz archive

I want to write a c-program which reads a textfile from a tar.gz archive.
How can I do it?
# 2  
Old 03-10-2003
Use GNU tar and extract the file to stdout

Code:
tar -zxvOf filename.tar.gz somepath/yourfile.txt

The '-O' option tells tar to extract it to stdout.
# 3  
Old 03-13-2003
If your using KDE there's one built-in, its called Archiver.
# 4  
Old 03-13-2003
That's not what I wanted to now. My question was, if there is a function in c which allows to read a textfile from a tar.gz archive and put it in a variable.
# 5  
Old 03-13-2003
yes, there are a number of functions to use to call an outside program. you can use exec() to call GNU tar. i think i understand what you want to do, youd like to actually write the code to uncompress the archive your self, while yes you can do that, it is (arguably) a large amount of work that you dont have to do, you already have tar. if you really want to write your own archiver/decompressor you could always look at the source of gnu tar to start you off.

let me add though, that if you just want to let a user pick an archive and read the text file inside of it from within your program then all you need to do is call tar from exec().
# 6  
Old 06-13-2003
Hi,
i have tried to do it.....but....the system tell me that -x is invalidate option.....i wish to uncompress a file.....Do you have any suggestion or idea please?....
Thanks in advance,
Mary
# 7  
Old 06-13-2003
Tried to do what? Run the line of code listed above, in the second post? Which system / shell are you running on?
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

TAR Error - file changed as we read it

Hi All, I am getting the above error when I execute the following in a shell script called by Cron. tar -cvf ${WORKING_BACKUP_ROOT}/${TAR_ARCHIVE_FILE} . >/${BACKUP_ROOT}/${ARCHIVE_LOG} if then echo "`date` : ERROR occurred on creating tar file" ... (1 Reply)
Discussion started by: daveu7
1 Replies

2. Linux

tar archive

I have made tar archive of my system.. How can I make that tar archive to be bootable.. simply to install new linux from the archived tar file.. thanks in advance (8 Replies)
Discussion started by: Vit0_Corleone
8 Replies

3. Shell Programming and Scripting

How to read the content of the particular file from tar.Z without extracting?

Hi All, I want to read the content of the particular file from tar.Z without extracting. aaa.tar.Z contains a file called one.txt, I want to read the content of the one.txt without extracting. Please help me to read the content of it. Regards, Kalai. (12 Replies)
Discussion started by: kalpeer
12 Replies

4. Shell Programming and Scripting

Read specific file from a zip archive without extracting

Hi All, I would like to extract specific file from a zip archive. I have a zip archive "sample.zip". sample.zip contains few text files and images... text1.txt, text2.txt, pic.jpg etc... I need to read specific file "text2.txt" from "sample.zip" WITHOUT EXTRACTING the zip file. ... (4 Replies)
Discussion started by: sridharg
4 Replies

5. Shell Programming and Scripting

Tar archive issue

Hi, I make a tar archive: tar -czvf /path_to/cucu.tar.gz /path/dir_to_archive/ In the archive the /path/dir_to_archive/ is maintained for every file. I need that the archive to be made without the /path/dir_to_archive/ to contain only the files in /path/dir_to_archive/. Thanks,... (4 Replies)
Discussion started by: potro
4 Replies

6. UNIX for Dummies Questions & Answers

Extracting from a tar archive file

Can I extract files from an archive file (tar), where the filename includes the full directory path, to a different directory? For example the archive files may have a filename of /SrcFiles/XXX/filename.dat and I want to extract it to /SrcFiles/YYY/filename.dat. Since the archive file was... (1 Reply)
Discussion started by: nmalencia
1 Replies

7. UNIX for Dummies Questions & Answers

Q: tar archive help

hey how do you create a archive and add file to an existing archive. i keep getting an error: dir/#: No such file or directory currently using tar -cvfu name.tar files files searching from a word document each line having different file extention. Thanks in advance (1 Reply)
Discussion started by: nookie
1 Replies

8. UNIX for Dummies Questions & Answers

Archive (tar)

Hi, I want to archive below directories ex: /home/oracle/ddd0 /home/oracle/ddd1 /home/oracle/ddd2 I want a command(tar) which will let me archive the above directories excluding *.dmp(dump files), *.log(log files) in those directories. So the archived file doesn't have... (4 Replies)
Discussion started by: dreams5617
4 Replies

9. Shell Programming and Scripting

read list of filenames from text file, archive, and remove

I posted a week ago regarding this scripting question, but I need to revisit and have a few more questions answered.. User cfajohnson was extremely helpful with the archive script, but clarification on my part is needed to help steer the answer in a direction that works in this particular... (5 Replies)
Discussion started by: fxvisions
5 Replies

10. Shell Programming and Scripting

Read from file then purge or archive.

Hi All, I have a root directory /tmp and I want to purge files or archive files in its subsequent subfolders.I listed the path of files I want to purge(archive) and the #of days. (purge) DAYS PATH 7 /tmp/arsenal/* 5 /tmp/chelsea/* (archive? the same as above but different folders... (15 Replies)
Discussion started by: kayarsenal
15 Replies
Login or Register to Ask a Question