- Community Home
- >
- Servers and Operating Systems
- >
- Operating System - HP-UX
- >
- System Administration
- >
- Re: command to find and tar files
-
- Forums
-
Blogs
- Hybrid Cloud
- Edge
- Data & AI
- Working in Tech
- AI Insights
- Alliances
- Around the Storage Block
- Behind the scenes at Labs
- Careers in Tech
- HPE Storage Tech Insiders
- Inspiring Progress
- IoT at the Edge
- My Learning Certification
- OEM Solutions
- Servers: The Right Compute
- Shifting to Software-Defined
- Telecom IQ
- Transforming IT
- HPE Blog, Austria, Germany & Switzerland
- Blog HPE, France
- HPE Blog, Italy
- HPE Blog, Japan
- HPE Blog, Russia
- HPE Blog, UK & Ireland
- Blogs
-
Quick Links
- Community
- Getting Started
- FAQ
- Ranking Overview
- Rules of Participation
- Contact
- Email us
- Tell us what you think
- Information Libraries
- Integrated Systems
- Networking
- Servers
- Storage
- Other HPE Sites
- Support Center
- Aruba Airheads Community
- Enterprise.nxt
- HPE Dev Community
- Cloud28+ Community
- Marketplace
-
Forums
-
Blogs
-
Information
-
English
- 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
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
09-14-2009 05:33 AM
09-14-2009 05:33 AM
command to find and tar files
I am looking for a one liner which finds all files starting with string "back" and then tars it.
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
09-14-2009 05:41 AM
09-14-2009 05:41 AM
Re: command to find and tar files
Pete
Pete
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
09-14-2009 05:51 AM
09-14-2009 05:51 AM
Re: command to find and tar files
You could do:
# cd /path && tar -cvf /tmp/myarchive $(find . -type f -name "*back*)
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
09-14-2009 05:54 AM
09-14-2009 05:54 AM
Re: command to find and tar files
Backup everything in /usr that starts with "pass":
find /usr -name "pass*" | pax -wf /tmp/mypassarchive.pax
cpio would do the trick as well...
HTH
Duncan
I am an HPE Employee

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
09-14-2009 06:18 AM
09-14-2009 06:18 AM
Re: command to find and tar files
> files to archive from stdin [...]
GNU "tar" has an option for that, too.
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
09-14-2009 06:55 PM
09-14-2009 06:55 PM
Re: command to find and tar files
As everybody said here one more example
from where you want to search from root "/" or some specific directiory from root "/" give the following command.
#find / -xdev -name back* | tar -xvf back.tar
for other location suppose /home then do like this
#find /home -xdev -name back* | tar -xvf back.tar
with cpio find from current directiory
#find . -print -depth |cpio -ov >tree.cpio
This will retrieve the files archived in the file directory.
#cpio -idv < tree.cpio
Suraj
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
09-15-2009 12:38 AM
09-15-2009 12:38 AM
Re: command to find and tar files
find . -type f | while read a
do
b="$( dd bs=4 count=1 if=$a 2>/dev/null |vis)"
if [ "$b" = "back" ]
then
echo $a
fi
done| xargs tar cvf /tmp/mytar.tar
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
09-15-2009 12:52 AM
09-15-2009 12:52 AM
Re: command to find and tar files
myM=/tmp/m$$
echo "0\tstring\tback\tmybackfile >$myM
find . -type f | xargs file -m $myM| grep "\tmybackfile" |cut -d : -f | xargs tar cvf /tmp/mytarfile.tar
I used "file" to check the beginning of each file
defining a magic entry
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
09-15-2009 12:56 AM
09-15-2009 12:56 AM
Re: command to find and tar files
find . -type f | xargs file -m $myM| grep "\tmybackfile" |cut -d : -f 1 | xargs tar cvf /tmp/mytarfile.tar
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
09-15-2009 01:50 AM
09-15-2009 01:50 AM
Re: command to find and tar files
Or you can use .tar: ... | pax -wf /tmp/mypassarchive.tar
>Suraj: find / -xdev -name back* | tar -xvf back.tar
As mentioned, this won't work without gnu tar or pax.
Hewlett Packard Enterprise International
- Communities
- HPE Blogs and Forum
© Copyright 2019 Hewlett Packard Enterprise Development LP