Sponsored Content
Full Discussion: Extracting .tar.gz files
Top Forums Shell Programming and Scripting Extracting .tar.gz files Post 302985128 by kristinu on Saturday 5th of November 2016 06:25:14 PM
Old 11-05-2016
I am specifying the directories where the extraction is to take place in the variable argv_dir. For example having argv_dir="graphics" is giving me the error

Code:
./untar.sh: line 62: cd: graphics/maverik: No such file or directory
./untar.sh: line 62: cd: graphics/panorama: No such file or directory
./untar.sh: line 62: cd: graphics/guile-opengl: No such file or directory
./untar.sh: line 62: cd: graphics/3dldf: No such file or directory
./untar.sh: line 62: cd: graphics/plotutils: No such file or directory
./untar.sh: line 62: cd: graphics/gpaint: No such file or directory
./untar.sh: line 62: cd: graphics/dia: No such file or directory
./untar.sh: line 62: cd: graphics/gift: No such file or directory
./untar.sh: line 62: cd: graphics/libxmi: No such file or directory
./untar.sh: line 62: cd: graphics/xaos: No such file or directory
./untar.sh: line 62: cd: graphics/gimp: No such file or directory
./untar.sh: line 62: cd: graphics/gsegrafix: No such file or directory

The code is as follows

Code:
for f in ${argv_dir} ; do

  find "${f}" -type d |
  while read dir
  do
    cd "${dir}" || continue
    for archive in *.tar.gz
    do
      if [ -r "./$archive" ]; then
        echo "$dir"
        echo -e "tar -zxf ./$archive\n"
        #tar -zxf ./$archive
      fi
    done
  done

done

However when I use find "$(pwd)/$f" -type d things work ok

I want to be able to use both a relative path or a full path in the variable f

Last edited by kristinu; 11-05-2016 at 07:53 PM..
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

error while extracting using TAR

Hi folks, When I am extracting an archive using the: tar -xvf /dev/rmt0 command i get the following error: x ./GRBD8901/GRBR006T, 1763253368 bytes, 3443855 media blocks. tar: 0511-197 ./GRBD8901/GRBR006T: Cannot write data extracted with the tar command: ... (7 Replies)
Discussion started by: Erik Rooijmans
7 Replies

2. Shell Programming and Scripting

bash - batch script for extracting one file from multiple tar files

so i have hundreds of files named history.20071112.tar (history.YYYYMMDD.tar) and im looking to extract one file out of each archive called status_YYYYMMDDHH:MM.lis here is what i have so far: for FILE in `cat dirlist` do tar xvf $FILE ./status_* done dirlist is a text... (4 Replies)
Discussion started by: kuliksco
4 Replies

3. Shell Programming and Scripting

Extracting .tar files.

Hey guys complete n00b here so I'll try my best at explaining. I'm creating a backup and restore utility and decided to use tar. I create a backup folder in each user's account and when backing up (say word processing files), I use the following: tar cvf /home/user/backup/wpbackup.tar... (2 Replies)
Discussion started by: EwanD
2 Replies

4. UNIX for Dummies Questions & Answers

Extracting specific files from a tar file in HP-UX

I have tried: tar -xfv mytarfile.tar archive/tabv/* tar -xfv mytarfile.tar --wildcards 'archive/tabv/*' tar -xf mytarfile.tar -v --wildcards 'archive/tabv/*' tar -xfv mytarfile.tar --wildcards --no-anchored 'archive/tabv/*' tar -xfv mytarfile.tar --wildcards `archive/tabv/*` and none... (5 Replies)
Discussion started by: zapper222
5 Replies

5. UNIX for Advanced & Expert Users

extracting multuiple tar files with while and read

Is anyone out there? I'm trying to run a script i wrote that extracts multiple .tar files in succession by pasting it into standard input. It does extract them all but I cant get it to stop looping and when I hit enter I get a tar command error like its still looking for files to extract. ie; ... (2 Replies)
Discussion started by: commoja
2 Replies

6. Shell Programming and Scripting

tar command to explore multiple layers of tar and tar.gz files

Hi all, I have a tar file and inside that tar file is a folder with additional tar.gz files. What I want to do is look inside the first tar file and then find the second tar file I'm looking for, look inside that tar.gz file to find a certain directory. I'm encountering issues by trying to... (1 Reply)
Discussion started by: bashnewbee
1 Replies

7. Shell Programming and Scripting

Extract contents of tar ball without extracting files

Hi, I'm using a tar command tar -xOvf /home/mytar.tar My intention is to extract data in files which are inside various directories, without extracting files to the disk. Is this the best way to achieve it? Thanks, Chetan (3 Replies)
Discussion started by: chetan.c
3 Replies

8. Shell Programming and Scripting

Bash not removing all .tar.bz2 files after extracting

In the bash below each .tar.bz2 (usually 2) are extracted and then the original .tar.bz2 is removed. However, only one (presumably the first extracted) is being removed, however both are extracted. I am not sure why this is? Thank you :). tar.bz2 folders in /home/cmccabe/Desktop/NGS/API ... (3 Replies)
Discussion started by: cmccabe
3 Replies

9. UNIX for Beginners Questions & Answers

Linux read specific content file from tar.gz files without extracting

hello i wish to write the result of these below conditions in a file: 1. in a specific folder, i have many tar.gz files. 2. each tar.gz file contains ".dat" file in sub folders. 3. i wish to get the full path of these .dat files, if i find in it a specific word ("ERROR24"). 4. all this... (6 Replies)
Discussion started by: jimmyjames9
6 Replies

10. Shell Programming and Scripting

Compare 2 files tar.lzo with/without extracting

Hi Guys, I have 2 compressed files tar.lzo and having many subdirectories inside it. I would like to know which files having the difference in terms of size/content. I am using bash shell and unix server example:- file1 :- abc.tar.lzo file2 :- xyz.tar.lzo Result:- ... (4 Replies)
Discussion started by: himanshupant
4 Replies
SENDFILES(1)                                                         [nmh-1.5]                                                        SENDFILES(1)

NAME
sendfiles - send multiple files via a MIME message SYNOPSIS
sendfiles [delay] mailpath subject file1 [file2 ...] DESCRIPTION
The shell script sendfiles, is used to send a collection of files and directories via electronic mail. sendfiles mailpath "subject" files ... sendfiles will archive the files and directories you name with the tar command, and then mail the compressed archive to the "mailpath" with the given "subject". The archive will be automatically split up into as many messages as necessary in order to get past most mailers. Sometimes you want sendfiles to pause after posting a partial message. This is usually the case when you are running sendmail and expect to generate a lot of partial messages. If the first argument given to sendfiles starts with a dash, then it is interpreted as the number of seconds to pause in between postings, e.g., sendfiles -30 mailpath "subject" files ... will pause 30 seconds in between each posting. Extracting the Received Files When these messages are received, invoke mhstore once for the list of messages. The default is for mhstore to store the combined parts as a new message in the current folder, although this can be changed using storage formatting strings. You can then use mhlist to find out what's inside; possibly followed by mhstore again to write the archive to a file where you can subsequently uncompress and untar it. For instance: % mhlist 5-8 msg part type/subtype size description 5 message/partial 47K part 1 of 4 6 message/partial 47K part 2 of 4 7 message/partial 47K part 3 of 4 8 message/partial 18K part 4 of 4 % mhstore 5-8 reassembling partials 5,6,7,8 to folder inbox as message 9 % mhlist -verbose 9 msg part type/subtype size description 9 application/octet-stream 118K (extract with uncompress | tar xvpf -) type=tar conversions=compress % mhstore 9 % uncompress < 9.tar.Z | tar xvpf - Alternately, by using the -auto switch, mhstore will automatically do the extraction for you: % mhlist 5-8 msg part type/subtype size description 5 message/partial 47K part 1 of 4 6 message/partial 47K part 2 of 4 7 message/partial 47K part 3 of 4 8 message/partial 18K part 4 of 4 % mhstore 5-8 reassembling partials 5,6,7,8 to folder inbox as message 9 % mhlist -verbose 9 msg part type/subtype size description 9 application/octet-stream 118K (extract with uncompress | tar xvpf -) type=tar conversions=compress % mhstore -auto 9 -- tar listing appears here as files are extracted As the second tar listing is generated, the files are extracted. A prudent user will never put -auto in the .mh_profile file. The correct procedure is to first use mhlist to find out what will be extracted. Then mhstore can be invoked with -auto to perform the extraction. FILES
$HOME/.mh_profile The user profile PROFILE COMPONENTS
Path: To determine the user's nmh directory Current-Folder: To find the default current folder SEE ALSO
mhbuild(1), mhlist(1), mhshow(1), mhstore(1). Proposed Standard for Message Encapsulation (RFC-934) DEFAULTS
`-noverbose' CONTEXT
None MH.6.8 11 June 2012 SENDFILES(1)
All times are GMT -4. The time now is 09:22 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy