Is possible to remove “on fly” the full path using tar?

Multi tool use
Multi tool use

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP











up vote
-1
down vote

favorite












I have some mp3 on various dir.
I did



find $HOME -name *.mp3|pax -wf arch.tar


The command works fine,but when extract, it recreate the full dirs
for example



tar -tvf arch.tar


Return



dir1/dir2/sound.mp3
dir3/music.mp3
dir4/dir5/anotherdir/anothermusic.mp3


When extract of course will create a lot of dirs.
My desire is a thing like this



find $HOME -name *.mp3|pax -w"possibleoption" -f arch.tar


To obtain an archive like this



/sound.mp3
/music.mp3
/anothermusic.mp3


I know is not safe,but is possible to strip dir path on fly?



p.s= I used pax command for example, but the classical tar is also good







share|improve this question
















  • 1




    Please look on this stackoverflow.com/questions/14295771/…
    – mariaczi
    Apr 10 at 11:10










  • Add as answer,if none put a better answer I can vote as solution
    – elbarna
    Apr 10 at 11:25














up vote
-1
down vote

favorite












I have some mp3 on various dir.
I did



find $HOME -name *.mp3|pax -wf arch.tar


The command works fine,but when extract, it recreate the full dirs
for example



tar -tvf arch.tar


Return



dir1/dir2/sound.mp3
dir3/music.mp3
dir4/dir5/anotherdir/anothermusic.mp3


When extract of course will create a lot of dirs.
My desire is a thing like this



find $HOME -name *.mp3|pax -w"possibleoption" -f arch.tar


To obtain an archive like this



/sound.mp3
/music.mp3
/anothermusic.mp3


I know is not safe,but is possible to strip dir path on fly?



p.s= I used pax command for example, but the classical tar is also good







share|improve this question
















  • 1




    Please look on this stackoverflow.com/questions/14295771/…
    – mariaczi
    Apr 10 at 11:10










  • Add as answer,if none put a better answer I can vote as solution
    – elbarna
    Apr 10 at 11:25












up vote
-1
down vote

favorite









up vote
-1
down vote

favorite











I have some mp3 on various dir.
I did



find $HOME -name *.mp3|pax -wf arch.tar


The command works fine,but when extract, it recreate the full dirs
for example



tar -tvf arch.tar


Return



dir1/dir2/sound.mp3
dir3/music.mp3
dir4/dir5/anotherdir/anothermusic.mp3


When extract of course will create a lot of dirs.
My desire is a thing like this



find $HOME -name *.mp3|pax -w"possibleoption" -f arch.tar


To obtain an archive like this



/sound.mp3
/music.mp3
/anothermusic.mp3


I know is not safe,but is possible to strip dir path on fly?



p.s= I used pax command for example, but the classical tar is also good







share|improve this question












I have some mp3 on various dir.
I did



find $HOME -name *.mp3|pax -wf arch.tar


The command works fine,but when extract, it recreate the full dirs
for example



tar -tvf arch.tar


Return



dir1/dir2/sound.mp3
dir3/music.mp3
dir4/dir5/anotherdir/anothermusic.mp3


When extract of course will create a lot of dirs.
My desire is a thing like this



find $HOME -name *.mp3|pax -w"possibleoption" -f arch.tar


To obtain an archive like this



/sound.mp3
/music.mp3
/anothermusic.mp3


I know is not safe,but is possible to strip dir path on fly?



p.s= I used pax command for example, but the classical tar is also good









share|improve this question











share|improve this question




share|improve this question










asked Apr 10 at 11:06









elbarna

3,76893477




3,76893477







  • 1




    Please look on this stackoverflow.com/questions/14295771/…
    – mariaczi
    Apr 10 at 11:10










  • Add as answer,if none put a better answer I can vote as solution
    – elbarna
    Apr 10 at 11:25












  • 1




    Please look on this stackoverflow.com/questions/14295771/…
    – mariaczi
    Apr 10 at 11:10










  • Add as answer,if none put a better answer I can vote as solution
    – elbarna
    Apr 10 at 11:25







1




1




Please look on this stackoverflow.com/questions/14295771/…
– mariaczi
Apr 10 at 11:10




Please look on this stackoverflow.com/questions/14295771/…
– mariaczi
Apr 10 at 11:10












Add as answer,if none put a better answer I can vote as solution
– elbarna
Apr 10 at 11:25




Add as answer,if none put a better answer I can vote as solution
– elbarna
Apr 10 at 11:25










1 Answer
1






active

oldest

votes

















up vote
3
down vote



accepted










These variations all assume that you've created an archive with the original path stored in the archive itself. They transform the path when listing/extracting the archive.



Using pax with its -s flag:



pax -f archive.tar -s '@.*/@/@' '*.mp3'


Add -r at the start to actually extract the files.



With BSD tar:



tar -tf archive.tar -s '@.*/@/@' '*.mp3'


Change -t to -x to actually extract the files.



With GNU tar:



tar -tPf archive.tar --transform 's@.*/@/@' --show-transformed-names --wildcards '*.mp3'


Change -t to -x to actually extract the files.



The string replacement will remove the path stored in the archive and replace it with a single /.




The equivalent operation for creating an archive with files whose pathnames are read from standard input (transforming the names by replacing the path with /):



pax:



pax -w -f archive.tar -s '@.*/@/@'


BSD tar:



tar -c -f archive.tar -s '@.*/@/@'


GNU tar:



tar -c -f archive.tar --transform='s@.*/@/@' --files-from=-





share|improve this answer






















  • pax works fine with find,tar give error if read from stdin with those options
    – elbarna
    Apr 10 at 12:30










  • @elbarna See updated answer.
    – Kusalananda
    Apr 10 at 12:49










  • Ok,perfect,voted as solution
    – elbarna
    Apr 10 at 14:05










Your Answer







StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "106"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
convertImagesToLinks: false,
noModals: false,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);








 

draft saved


draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f436747%2fis-possible-to-remove-on-fly-the-full-path-using-tar%23new-answer', 'question_page');

);

Post as a guest






























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes








up vote
3
down vote



accepted










These variations all assume that you've created an archive with the original path stored in the archive itself. They transform the path when listing/extracting the archive.



Using pax with its -s flag:



pax -f archive.tar -s '@.*/@/@' '*.mp3'


Add -r at the start to actually extract the files.



With BSD tar:



tar -tf archive.tar -s '@.*/@/@' '*.mp3'


Change -t to -x to actually extract the files.



With GNU tar:



tar -tPf archive.tar --transform 's@.*/@/@' --show-transformed-names --wildcards '*.mp3'


Change -t to -x to actually extract the files.



The string replacement will remove the path stored in the archive and replace it with a single /.




The equivalent operation for creating an archive with files whose pathnames are read from standard input (transforming the names by replacing the path with /):



pax:



pax -w -f archive.tar -s '@.*/@/@'


BSD tar:



tar -c -f archive.tar -s '@.*/@/@'


GNU tar:



tar -c -f archive.tar --transform='s@.*/@/@' --files-from=-





share|improve this answer






















  • pax works fine with find,tar give error if read from stdin with those options
    – elbarna
    Apr 10 at 12:30










  • @elbarna See updated answer.
    – Kusalananda
    Apr 10 at 12:49










  • Ok,perfect,voted as solution
    – elbarna
    Apr 10 at 14:05














up vote
3
down vote



accepted










These variations all assume that you've created an archive with the original path stored in the archive itself. They transform the path when listing/extracting the archive.



Using pax with its -s flag:



pax -f archive.tar -s '@.*/@/@' '*.mp3'


Add -r at the start to actually extract the files.



With BSD tar:



tar -tf archive.tar -s '@.*/@/@' '*.mp3'


Change -t to -x to actually extract the files.



With GNU tar:



tar -tPf archive.tar --transform 's@.*/@/@' --show-transformed-names --wildcards '*.mp3'


Change -t to -x to actually extract the files.



The string replacement will remove the path stored in the archive and replace it with a single /.




The equivalent operation for creating an archive with files whose pathnames are read from standard input (transforming the names by replacing the path with /):



pax:



pax -w -f archive.tar -s '@.*/@/@'


BSD tar:



tar -c -f archive.tar -s '@.*/@/@'


GNU tar:



tar -c -f archive.tar --transform='s@.*/@/@' --files-from=-





share|improve this answer






















  • pax works fine with find,tar give error if read from stdin with those options
    – elbarna
    Apr 10 at 12:30










  • @elbarna See updated answer.
    – Kusalananda
    Apr 10 at 12:49










  • Ok,perfect,voted as solution
    – elbarna
    Apr 10 at 14:05












up vote
3
down vote



accepted







up vote
3
down vote



accepted






These variations all assume that you've created an archive with the original path stored in the archive itself. They transform the path when listing/extracting the archive.



Using pax with its -s flag:



pax -f archive.tar -s '@.*/@/@' '*.mp3'


Add -r at the start to actually extract the files.



With BSD tar:



tar -tf archive.tar -s '@.*/@/@' '*.mp3'


Change -t to -x to actually extract the files.



With GNU tar:



tar -tPf archive.tar --transform 's@.*/@/@' --show-transformed-names --wildcards '*.mp3'


Change -t to -x to actually extract the files.



The string replacement will remove the path stored in the archive and replace it with a single /.




The equivalent operation for creating an archive with files whose pathnames are read from standard input (transforming the names by replacing the path with /):



pax:



pax -w -f archive.tar -s '@.*/@/@'


BSD tar:



tar -c -f archive.tar -s '@.*/@/@'


GNU tar:



tar -c -f archive.tar --transform='s@.*/@/@' --files-from=-





share|improve this answer














These variations all assume that you've created an archive with the original path stored in the archive itself. They transform the path when listing/extracting the archive.



Using pax with its -s flag:



pax -f archive.tar -s '@.*/@/@' '*.mp3'


Add -r at the start to actually extract the files.



With BSD tar:



tar -tf archive.tar -s '@.*/@/@' '*.mp3'


Change -t to -x to actually extract the files.



With GNU tar:



tar -tPf archive.tar --transform 's@.*/@/@' --show-transformed-names --wildcards '*.mp3'


Change -t to -x to actually extract the files.



The string replacement will remove the path stored in the archive and replace it with a single /.




The equivalent operation for creating an archive with files whose pathnames are read from standard input (transforming the names by replacing the path with /):



pax:



pax -w -f archive.tar -s '@.*/@/@'


BSD tar:



tar -c -f archive.tar -s '@.*/@/@'


GNU tar:



tar -c -f archive.tar --transform='s@.*/@/@' --files-from=-






share|improve this answer














share|improve this answer



share|improve this answer








edited Apr 10 at 13:09

























answered Apr 10 at 11:27









Kusalananda

102k13200317




102k13200317











  • pax works fine with find,tar give error if read from stdin with those options
    – elbarna
    Apr 10 at 12:30










  • @elbarna See updated answer.
    – Kusalananda
    Apr 10 at 12:49










  • Ok,perfect,voted as solution
    – elbarna
    Apr 10 at 14:05
















  • pax works fine with find,tar give error if read from stdin with those options
    – elbarna
    Apr 10 at 12:30










  • @elbarna See updated answer.
    – Kusalananda
    Apr 10 at 12:49










  • Ok,perfect,voted as solution
    – elbarna
    Apr 10 at 14:05















pax works fine with find,tar give error if read from stdin with those options
– elbarna
Apr 10 at 12:30




pax works fine with find,tar give error if read from stdin with those options
– elbarna
Apr 10 at 12:30












@elbarna See updated answer.
– Kusalananda
Apr 10 at 12:49




@elbarna See updated answer.
– Kusalananda
Apr 10 at 12:49












Ok,perfect,voted as solution
– elbarna
Apr 10 at 14:05




Ok,perfect,voted as solution
– elbarna
Apr 10 at 14:05












 

draft saved


draft discarded


























 


draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f436747%2fis-possible-to-remove-on-fly-the-full-path-using-tar%23new-answer', 'question_page');

);

Post as a guest













































































LeVD,4IkMMgOuh8SI 5x 5SCHTqf50 UZlefj,OGC7Qa23,NppL,W4jBlnDPw,eiroBsQFNXJcZARjQP46D5ZYbkS
WhsS1MgbKbdsRe3tHM1V YNm BiAO,w8JQBGxbTLjZNHWgUgzLJVPz29qi8B

Popular posts from this blog

How to check contact read email or not when send email to Individual?

How many registers does an x86_64 CPU actually have?

Displaying single band from multi-band raster using QGIS