I have tar ball "data.tar" which consists of many files from different directories.
If I untar a file using following command, it will untar file to location /input/data
I want the file to be untar in current directory and or any other directory of my choice. Also it should not overwrite if there is a file with the same name in the directory.
I searched and found that pax command could do it. But could not find the exact command for my need.
I found the following command but looks like the below command will untar all files and not specific file.
I don't use pax very often, but I think this will do what you want:
It should extract only input.txt to the current directory, and should not try to create the directory structure (/foo/bar in this case) above it. If you use the 'p' option on the substitution parameter (-s) it will print all of the filenames, not just the ones that match the ones given on the command line. The -k option should issue a warning, and not overwrite the file already on disk, if a file exists.
I used bangs (!) in the substitution parameter as it avoids needing to escape the slant and thus is easier to read.
I also believe you can use a pattern so somethingg like "/foo/bar/*.txt" would pull all .txt files from the archive and place them in the current directory. (Quotes are needed here to prevent glob expansion matching anything in the current driectory.)
Hope this gets you a bit further along.
Last edited by agama; 03-26-2012 at 09:33 PM..
Reason: icode tags :)
I don't use pax very often, but I think this will do what you want:
It should extract only input.txt to the current directory, and should not try to create the directory structure (/foo/bar in this case) above it. If you use the 'p' option on the substitution parameter (-s) it will print all of the filenames, not just the ones that match the ones given on the command line. The -k option should issue a warning, and not overwrite the file already on disk, if a file exists.
I used bangs (!) in the substitution parameter as it avoids needing to escape the slant and thus is easier to read.
I also believe you can use a pattern so somethingg like "/foo/bar/*.txt" would pull all .txt files from the archive and place them in the current directory. (Quotes are needed here to prevent glob expansion matching anything in the current driectory.)
Hope this gets you a bit further along.
Thanks agama this works great except a minor change is needed.
Instead of untarring the file in current directory i would like to untar it to any other directory of my choice. What should be the change.
I understood what the command is doing except the following piece.
I understand it is replacing the directory path but not completley understand it.
If I were writing a script to do this I would cd to the target directory for unload, and then invoke pax. You can put it all in parens (example below) which will eliminate the need to cd back to the original directory:
The substitute command removes all characters from the front of the string through the last slant so that the directory name is removed. It's the same as this sed expression: s/.*\//. I use bangs (!) so as to avoid needing to escape the slant in the pattern.
Hello,
I have a tape backup (it was made using dd/tar) and I want to use dd/pax to restore tape to disk, in IBM AIX 7.2.
I can restore from tape using example below without issues.
#/usr/bin/dd bs=128k if=/dev/rmt0 | /usr/bin/pax -r -v /home/c3rb3rus/utils/*
USTAR format archive... (6 Replies)
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)
tar has the -T operand for reading patterns from a file.
Is there any way to read patterns from stdin, without creating a temp file? I would like to avoid iterating over the archive repeatedly (e.g. with a loop or xargs) as this is a large archive and we're only extracting a small number of... (2 Replies)
hi
I am using this command
pax -f /Unix/codes/code.tar -r -s::/Unix/archive:
objective is to transfer tar file /Unix/codes/code.tar to /Unix/archive with untarring done . For this reason i am using pax and not tar -xvf as we cant specify untarred destination in that
the problem is... (2 Replies)
Hi all,
4 files are returned when i issue 'find . -mtime -1 -type f -ls'.
./ora_475244.aud
./ora_671958.aud
./ora_934052.aud
./ora_934050.aud
However, when I issued the below command:
tar -cvf test.tar `find . -mtime -1 -type f`, the tar file only contains the 1st file -... (2 Replies)
we created a TAR file ( souce /opt/oracle/10.2) . If we want to extract it diff directory say (/tmp) . I know we can use pax to do this .but inside TAR we have absolute path ref . if we pax does it replaces absolute path in TAR ?
Thanks (1 Reply)
Hi, I am using AIX 5.3.0.0 and Ultrium LTO3 Tape Drive as rmt1. I have backup some of my database file using command "pax" as
pax -wvf /dev/rmt1 "./data01/abc.dmp"
But when I tried to read the file from tape by issuing the command,
pax -vf /dev/rmt1
The error message displayed as
pax:... (4 Replies)
I am having trouble with the pax command on Saris. I want to sue it to untar a file to a different directory. So if mytar.tar conatins files that were in /u02/mydir/mydir2/mydir3, I want to untar them to /export/home/mydir.
An example I have is:
pax -r -s... (2 Replies)
I have a .tar file consisting of text and binary files. I ftp'd the .tar file using ftp binary.
when I did the pax to unwind the tar file, I noiticed that the text files were encoded in binary.
**How would I retain the text characteristics of the ascii text files, while also keeping the... (11 Replies)