1847176 Members
6018 Online
110263 Solutions
New Discussion

Re: tar help

 
Tim Howell
Frequent Advisor

tar help

Hello experts! I would like to use tar to create an archive of files in a directory EXCLUDING files with certain "extensions" like *.o and *.x
The problem with listing what I want is there are a host of other files extensions that may change over time.
I must use tar, so does anyone know any good tricks?
if only we knew...
6 REPLIES 6
Patrick Wallek
Honored Contributor

Re: tar help

I would create the file list dynamically and exclude the files you don't want.

Something like this:

# ls -1 | grep -v -e "*.o" -e "*.x" > file_list

# tar -cvf filename.tar $(cat file_list)
Cheryl Griffin
Honored Contributor

Re: tar help

How about using the script Steven provided here
http://forums1.itrc.hp.com/service/forums/bizsupport/parseCurl.do?CURL=%2Fcm%2FQuestionAnswer%2F1%2C%2C0x4d7850011d20d6118ff40090279cd0f9%2C00.html&forumId=2&admit=716493758+1077718189425+28353475

the tar.exclude would contain
*.o
*.x

There were a lot of good answers in that thread.
"Downtime is a Crime."
Geoff Wild
Honored Contributor

Re: tar help

What about creating a list of files you want to back up?

LOGFILE=/tmp/backup.log
TARFILE=`date |awk '{print ($1)}'`.tar

tar -cvf /home/backups/$TARFILE `cat /root/backupfiles` >>$LOGFILE 2>&1

Rgds...Geoff
Proverbs 3:5,6 Trust in the Lord with all your heart and lean not on your own understanding; in all your ways acknowledge him, and he will make all your paths straight.
H.Merijn Brand (procura
Honored Contributor

Re: tar help

Cheryl, Steven's script has the potential danger of hitting the dreaded argument list to big error.
And his grep has the potential danger of misinterpreting files that have wildcards and/or whitespace in their names, which - now we have samba and CiFS - happens far too often when users give phony names to the (edited to comply with ITRC guidelines) stuf they save on our precious shares

GNU tar is the solution

Enjoy, Have FUN! H.Merijn
Enjoy, Have FUN! H.Merijn
Ravi_8
Honored Contributor

Re: tar help

Hi,

gnu tar might be having this option
never give up
Cheryl Griffin
Honored Contributor

Re: tar help

Thank you Procura, I will keep that in mind.


(0 points please)
"Downtime is a Crime."