31
14
The find command gives this output:
[root@localhost /]# find var/log/ -iname anaconda.* var/log/anaconda.log var/log/anaconda.xlog var/log/anaconda.yum.log var/log/anaconda.syslog var/log/anaconda.program.log var/log/anaconda.storage.log
After combining with tar it's showing this output:
[root@localhost /]# find var/log/ -iname anaconda.* -exec tar -cvf file.tar {} \; var/log/anaconda.log var/log/anaconda.xlog var/log/anaconda.yum.log var/log/anaconda.syslog var/log/anaconda.program.log var/log/anaconda.storage.log
But while listing tar file it's showing only a single file
[root@localhost /]# tar -tvf file.tar -rw------- root/root 208454 2012-02-27 12:01 var/log/anaconda.storage.log
What I am doing wrong here?
With xargs I am getting this output:
[root@localhost /]# find var/log/ -iname anaconda.* | xargs tar -cvf file1.tar
Second question
While typing / in front of var, means find /var/log
why its giving this mesaage tar: Removing leading `/' from member names
[root@localhost /]# find /var/log/ -iname anaconda.* -exec tar -cvf file.tar {} \; tar: Removing leading `/' from member names /var/log/anaconda.log tar: Removing leading `/' from member names /var/log/anaconda.xlog tar: Removing leading `/' from member names /var/log/anaconda.yum.log tar: Removing leading `/' from member names /var/log/anaconda.syslog tar: Removing leading `/' from member names /var/log/anaconda.program.log tar: Removing leading `/' from member names /var/log/anaconda.storage.log
In a simple form what is the difference between in the following two?
find var/log
and find /var/log
1If you use
{} +
instead of{} \;
it will group results of find into one argument – Jason S – 2016-09-05T23:11:58.447This is semi+off topic, but going forward with the
find
command, you should quote the search term. It works without sometimes but not always. – nerdwaller – 2012-12-01T15:39:04.583