Extract files from tar ball without directory structure

Hi,
I have tar filw which has multiple directories which contain files.
When i extract using tar -xf the directory structure also get extracted.

I require only files and not directory structures as there will be overhead of moving the files again.

So i searched here and got a solution but i'm not able to understand what its doing.I've read the man pages but not able to get.
The Solution is like this.

pax -r -f tartest.tar -s'/tartest\///'

Please guide me to understand what its doing and what

means?.

Thanks,
Chetan.C

It doesn't remove all the path information. It just gets rid of the /tartest/.

It's a regular expression. It replaces tartest/ with nothing.

The backslashes are to get literal /'s into a string delimited with /'s.

Hi Corona,

Thanks.
So if i have the directoy structure in tar like below

/Folder1/Folder1.1/File1.txt
/folder2/Folder2.1/File2.txt

How can i use it to extract the files directly?

Thanks,
Chetan.C

Hi.

       --strip, --strip-components N
              Strips the first N components from archive members' pathnames
              when unpacking.

-- excerpt from GNU man tar, q.v.

The full manual is available at GNU tar manual - GNU Project - Free Software Foundation (FSF)

Best wishes ... cheers, drl

@chetan.c
What Operating System and version you have?

The long-term solution is to create your tar archives with relative paths.

When reading a tar archive with pax the simplest is to remove the leading solidus from the absolute filenames. Always practice your tar and pax commands with a small and expendable file before moving on to live data.

pax -r -f tartest.tar -s '/^\///'