- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- command to find and tar files
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
тАО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
- Mute
- Subscribe to RSS Feed
- Permalink
- 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
- Mute
- Subscribe to RSS Feed
- Permalink
- 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
- Mute
- Subscribe to RSS Feed
- Permalink
- 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
- Mute
- Subscribe to RSS Feed
- Permalink
- 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
- Mute
- Subscribe to RSS Feed
- Permalink
- 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
- Mute
- Subscribe to RSS Feed
- Permalink
- 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
- Mute
- Subscribe to RSS Feed
- Permalink
- 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
- Mute
- Subscribe to RSS Feed
- Permalink
- 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
- Mute
- Subscribe to RSS Feed
- Permalink
- 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.