I want to tar some Python files and send it across a server. I do:
find /some/path -iname "*.py" -exec tar czfv python_files.tar {} +
Followed by:
pv python_files.tar| ssh some_user@some_server 'cat | tar xz -C /some/path/on/server'
Unfortunately when I SSH on the server I see the full directory structure has been sent across the server and I find my python files like that:
/some/path/on/server/complicated/sub/directory/some_file.py
/some/path/on/server/another/complicated/sub/directory/some_file2.py
What I want is my files to be at the root:
/some/path/on/server/some_file.py
/some/path/on/server/some_file2.py
What is the missing piece?
Best Answer
as per man tar (a long reading)
I used
all files were on same level.
sed expression
s:./.*/::
: (greedy) replace./.*/
by nothing.bonus:
will print dupplicate filename.