tar -xvf company_raw_2012-03-16.tgz --directory=/root/test --strip-components=4
I am using the following tar option to remove the leading directories and it is working as expected.
--strip-components NUMBER
strip NUMBER of leading components from file names before extraction
It works only when I know that there are going to be 4 sub-directories. I have tar files and I do not know if there will be 2, 3 or 4 folders inside. How do I strip the entire path and extract files in the given "directory" path.