Reputation: 95
How can a find statement be crafted to strip the leading slash off absolute path names and deliver items to add to the tar as relative path names in order to avoid the unwanted error: "tar: Removing leading `/' from member names" ?
The current statement:
# tar -zcvf /root/TEST1-strip-slash-find-statement.tar.gz `find /root/test -mmin -1450 -print`
Produces the following output on Ubuntu 16.04 LTS bash shell
tar: Removing leading `/' from member names
/root/test/
/root/test/file2.txt
/root/test/file3.txt
/root/test/file1.txt
/root/test/file4.txt
tar: Removing leading `/' from hard link targets
/root/test/file2.txt
/root/test/file3.txt
/root/test/file1.txt
/root/test/file4.txt
Find is sending leading slashes to tar: tar: Removing leading `/' from member names
How can the find statement be revised to first strip the leading slashes from the absolute path names, then send the relative path name to tar ?
When this command is run from crontab , the leading slash error results in numerous emails being sent about tar: Removing leading `/' from member names. I It is necessary to continue receiving emails for other errors, so disabling email sending with dev/null or mailto="" is not an option.
Upvotes: 0
Views: 554
Reputation: 88999
To get rid of "tar: Removing leading `/' from member names":
Add -C /
and remove leading /
from your paths.
tar -C / -zcvf /root/TEST1-strip-slash-find-statement.tar.gz `find /root/test -mmin -1450 -print | sed 's|^/||'`
Upvotes: 1