Extracting certain /paths/* using tar

forgive my ignorance.
I did a search of this sub-forum for "tar -xp" and variations on the same w\out success, so here goes...

Scenario:
filename.tar file.

Desired Task:
I want to be able to extract only files from the user's public_html folder (and all those under it as an option) from the archive.

Usual target path:
/home/$user/public_html/*
(the archive is on a nas, so extracting to the current directory where the archive lives will have to do, for now).

What I've tried:
tar --extract --file=-filename.tar $user (I think this worked, but I was i a hurry and at the end of a long day)

What I've read to try:
tar -xp <something> (haven't had the chance to try anything along these lines)

Thank you for your time and assistance.

User tar -tf <tarball> to verify the structure of the tarball first but you should be able to just name the directory to extract and it'll do that and all subdirs of it, thus:

tar xf tarball.tar /home/$user/public_html

Great!
I'll have a go of it today, I'm sure.

it works.

Thanks Smiling Dragon!

Happy to help :slight_smile: