- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- How to tar all files except select few
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
Forums
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
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
тАО11-18-2003 10:49 PM
тАО11-18-2003 10:49 PM
I remember reading this and also have used it once or twice. Iam unable to recollect now. Could anyone please let me know, how to tar all files except a, b, c, d, e and f
Thanks,
Madhu
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО11-18-2003 10:58 PM
тАО11-18-2003 10:58 PM
Re: How to tar all files except select few
tar -cvf /tmp/files.tar `cat /tmp/file_list.txt`
where /tmp/file_list.txt contains the files you want (including the full path)
eg
/etc/passwd
/etc/hosts
/var/adm/syslog
...
...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО11-18-2003 10:59 PM
тАО11-18-2003 10:59 PM
Re: How to tar all files except select few
tar cvf
Then use find to find the files/dirs you want, but use the negate -name (! -name
cd /tmp
find . ! -name
This will append all files in /tmp except file1 and file2 to your tarfile
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО11-18-2003 11:01 PM
тАО11-18-2003 11:01 PM
Re: How to tar all files except select few
if you have not a zillion files in your directory, and do not want to exclude a zillion files:
tar cvf tarfile `ls | grep -v -e "^file1$" -e "^file2$" `
regards,
Thierry.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО11-18-2003 11:01 PM
тАО11-18-2003 11:01 PM
Re: How to tar all files except select few
if a, b, c, etc just mean subdirs or files in the current directory it would be as easy as:
tar cvf /bigdir/tarfile `ls | grep -v -E "a|b|c|d|e|f"`
else it should be something like:
tar cvf /bigdir/tarfile `find . -xdev -type f | grep -v -E "a|b|c|d|e|f"`
Regards
Bernhard
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО11-18-2003 11:01 PM
тАО11-18-2003 11:01 PM
Re: How to tar all files except select few
#ls|egrep -v 'a|b|c' >/tmp/a/z;tar cvf a.tar `cat /tmp/a/z`
The best option would be 'find' instead of a 'ls'
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО11-18-2003 11:09 PM
тАО11-18-2003 11:09 PM
Re: How to tar all files except select few
In this case.
tar cvf tarfile a?* b?* c?* d?* e?* f?* [0-9g-z]*
will get them, unless you have wierd filenames beginning with non-alphanumerics.
-- Graham
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО11-18-2003 11:12 PM
тАО11-18-2003 11:12 PM
Re: How to tar all files except select few
I remember using ![#filename] ( or in some combination) of ! [] #, where filename is name of the file that has to be excluded in the tar.
Unable to get the right combination now.
Thanks,
Madhu
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО11-18-2003 11:27 PM
тАО11-18-2003 11:27 PM
Re: How to tar all files except select few
find . !-name
Gideon
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО11-18-2003 11:37 PM
тАО11-18-2003 11:37 PM
Re: How to tar all files except select few
That would be
tar cvf tarfile !(a|b|c|d|e|f)
--Graham
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО11-19-2003 12:14 AM
тАО11-19-2003 12:14 AM
Re: How to tar all files except select few
$ tar cvf ../all.tar !(d.txt | e.txt)
a a.txt 0 blocks
a b.txt 0 blocks
a c.txt 0 blocks
a d.txt 0 blocks
a e.txt 0 blocks
$ tar tvf ../all.tar
rw-r--r-- 47354/20 0 Nov 19 05:11 2003 a.txt
rw-r--r-- 47354/20 0 Nov 19 05:11 2003 b.txt
rw-r--r-- 47354/20 0 Nov 19 05:11 2003 c.txt
rw-r--r-- 47354/20 0 Nov 19 05:11 2003 d.txt
rw-r--r-- 47354/20 0 Nov 19 05:11 2003 e.txt
$
-Madhu
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО11-19-2003 12:19 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО11-19-2003 12:34 AM
тАО11-19-2003 12:34 AM
Re: How to tar all files except select few
-Madhu