moving multiple files --recursively using BSD | Unix Linux Forums | UNIX for Advanced & Expert Users

  Go Back    


UNIX for Advanced & Expert Users Expert-to-Expert. Learn advanced UNIX, UNIX commands, Linux, Operating Systems, System Administration, Programming, Shell, Shell Scripts, Solaris, Linux, HP-UX, AIX, OS X, BSD.

moving multiple files --recursively using BSD

UNIX for Advanced & Expert Users


Tags
cpio

Closed Thread    
 
Thread Tools Search this Thread Display Modes
    #1  
Old 08-30-2005
moxxx68's Avatar
moxxx68 moxxx68 is offline
Registered User
 
Join Date: Mar 2004
Last Activity: 17 December 2005, 5:40 AM EST
Posts: 301
Thanks: 0
Thanked 0 Times in 0 Posts
Tools moving multiple files --recursively using BSD

i am using a FreeBSD remote account and I have directory that holds a number of
other directories most of which posses *.tgz *.tar.bz2 *.gz files... on a linux system
i would use a find format such as this to locate and mv *.tgz and *.tar.bz2 files
find ./dir -type f -iname "*.t[argz]*[bz2]" -print | xargs mv --target-directory=dir

on bsd this doesn't work since the mv options are slightly differenr than gnu linux..

i used "find ./dir -depth -print | cpio -ov > tree.cpio" and mv the file to a said dir and
extracted the filesystem but i could not find a way to extract just the files using find,
xargs or cpio on the BSD system... what I had to do was ftp the file to my linux system
do all operations and scp the whole directory of extracted files back to the account..
how would i go about extracting just the files using find and xargs or cpio on BSD
without having to go through the rigmarole of ftping back forth between my linux
system and the remote account...
thanx moxxx68


excuse the grievance: i have a small typo that would make difference to anyone looking at
my post;;
find ./dir -type f -iname "*.t[arg]*[bz]2" -depth -print0 | cpio --null -pvd ./target-dir
without the print0 expression you might get a slightly different result.. unfortunately on some
bsd systems i am pretty sure that it doesn't exist ... i could be wrong though..

Last edited by moxxx68; 09-12-2005 at 08:16 AM.. Reason: typo ...
Sponsored Links
    #2  
Old 09-07-2005
lingam lingam is offline
Registered User
 
Join Date: Mar 2005
Last Activity: 24 November 2009, 11:48 PM EST
Location: shanghai China
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Not using FreeBSD , but if the following find command can display the files you want to move .
find ./dir -type f -iname "*.t[argz]*[bz2]" -print
then you might try this
#find ./dir -type f -iname "*.t[argz]*[bz2]" -print > /tmp/file.list
#tar cvf - `cat /tmp/file.list` | ( cd /target_dir;tar xvf - )
now you just have to remove the old files .
Sponsored Links
    #3  
Old 09-12-2005
moxxx68's Avatar
moxxx68 moxxx68 is offline
Registered User
 
Join Date: Mar 2004
Last Activity: 17 December 2005, 5:40 AM EST
Posts: 301
Thanks: 0
Thanked 0 Times in 0 Posts
thanx for the replay will try!
moxxx68
    #4  
Old 09-12-2005
moxxx68's Avatar
moxxx68 moxxx68 is offline
Registered User
 
Join Date: Mar 2004
Last Activity: 17 December 2005, 5:40 AM EST
Posts: 301
Thanks: 0
Thanked 0 Times in 0 Posts
Quote:
Not using FreeBSD , but if the following find command can display the files you want to move .
find ./dir -type f -iname "*.t[argz]*[bz2]" -print
then you might try this
#find ./dir -type f -iname "*.t[argz]*[bz2]" -print > /tmp/file.list
#tar cvf - `cat /tmp/file.list` | ( cd /target_dir;tar xvf - )
now you just have to remove the old files .
this worked to a certain extent but this command does the same thing although it is not quite what
i am looking for..
find . ./dir -type f -iname "*.t[argz]*[bz]2" -depth -print | cpio --null -pvd ./target-directory
this will do exactly what you did using tar... but still doesn't extract the files only.. my main
concern in the filesystem that I am using is speed since it is a large filesystem and has many
changes applied daily to the files.. using the above methods means i must go in and individually
extract each file one by one.. i think due to my using linux's "xargs mv --target-directory=./"
option using find all the time I may have over looked a few options that are basically simple
or too obvious .. . just for clarification i understand that only the selected files are transfrered
to the desired directory but they are still archived in their original directories since the all
the directories are transfered too empty or not.. what I need is to transfer just the files through
an extraction method to one said directory.. .
thanx moxxx68
Sponsored Links
Closed Thread

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Zip multiple files recursively via UNIX anou UNIX for Dummies Questions & Answers 3 02-06-2012 09:49 AM
Need help in moving files recursively jagadish_gaddam UNIX for Dummies Questions & Answers 1 07-06-2010 11:56 AM
Moving multiple files and renaming them on the fly daemongk Shell Programming and Scripting 1 06-08-2007 01:36 PM
moving and renaming multiple files rocinante Shell Programming and Scripting 1 06-07-2007 08:20 PM
moving files across multiple servers kymberm UNIX for Advanced & Expert Users 2 10-23-2002 12:04 PM



All times are GMT -4. The time now is 04:25 AM.