- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- using tar and grep together
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Discussions
Discussions
Forums
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-19-2004 04:52 AM
тАО05-19-2004 04:52 AM
using tar and grep together
I have a directory structure with 50000 sub-directories, totalling 30 gbytes.
i would like to tar it up, however, what i would lik eto do is grep out sub-directories with certain specific names in them.
e.g. grep -v sun and a grep -v irix or even a grep -v French
is there a way I can do all this on one command line?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-19-2004 05:58 AM
тАО05-19-2004 05:58 AM
Re: using tar and grep together
and you can do slick things like:
cd YOURbigDIRECTORY
/opt/tar/bin/tar --create --verbose --file=/var/appl/crazy.tar --exclude="*\/DNS
CACHE_INSTALLDIRhp11.11\/*" --exclude "*\/OraInstall200[2-4]-[0-9][0-9]-[0-9][0-
9]_[0-9][0-9]-[0-9][0-9]-[0-9][0-9]PM\/*" --exclude "*\/PHTXT\/*" --gzip ./*
The exclude will still create the upper directory entry, but it will NOT archive any files under it!
If you use gzip or compress on your archive, then you have to tell the --list option how the archive was compressed (--gzip in this case):
/opt/tar/bin/tar --list --file=/var/appl/crazy.tar --gzip|more
live free or die
harry
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-19-2004 06:49 AM
тАО05-19-2004 06:49 AM
Re: using tar and grep together
find /mydir -type d -print| grep -v irix | pax -wd -x utar >mysave.tar
HTH
-- Rod Hills
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-19-2004 06:55 AM
тАО05-19-2004 06:55 AM
Re: using tar and grep together
find ./ -prune ... | tar ...
an example using prune
http://forums1.itrc.hp.com/service/forums/questionanswer.do?admit=716493758+1084992752438+28353475&threadId=245727
or
find ./ | grep -vE "sun|irix|French" | tar
but you might exclude more then you think that way
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-19-2004 06:56 AM
тАО05-19-2004 06:56 AM
Re: using tar and grep together
you could try and bend the find command a litte and use the not operator for excluding filenames, e.g.:
# find . -type f ! -name "*sun*" ! -name "*French*"|xargs tar cvf - >mytar.tar
mytar.tar should be located out of reach of the find command.
regards,
John K.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-19-2004 07:17 AM
тАО05-19-2004 07:17 AM
Re: using tar and grep together
"tar" doesn't read the list of files to backup from stdin, I think you are thinking of "cpio".
John,
Unfortunatelly if their are a lot of directories the xargs command could run the tar command multiple times. Thus the file mytar.tar will have whatever the last tar command that was executed.
-- Rod Hills