Tar Error: Removing leading `/’ from member names

When archiving files with the tar command today, it kept prompting “tar: Removing leading `/’ from member names”

[root@zsf tmp]# tar -cvf test.tar /tmp/*

tar: Removing leading `/’ from member names

/tmp/123.tar

/tmp/1.txt

/tmp/2.tar

/tmp/P

tar: /tmp/test.tar: file is the archive; not dumped

Found a -P option in there to solve this problem

-P, –absolute-names

don’t strip leading ‘/’s from file names

Then we decided to test it

[root@zsf tmp]# tar -cvfP test1.tar /tmp/*

test1.tar

tar: Removing leading `/’ from member names

/tmp/123.tar

/tmp/1.txt

/tmp/2.tar

tar: /tmp/P: file is the archive; not dumped

/tmp/test1.tar

/tmp/test.tar

# Found a new error reported, why? It turns out that the -f option of the tar command must be followed by a file and nothing else. Immediately swap the f and P positions

[root@zsf tmp]# tar -cvPf test1.tar /tmp/*

/tmp/123.tar

/tmp/1.txt

/tmp/2.tar

/tmp/P

/tmp/test.tar

Done!

Similar Posts: