Sponsored Content
Top Forums UNIX for Advanced & Expert Users moving multiple files --recursively using BSD Post 83169 by moxxx68 on Monday 12th of September 2005 07:41:53 AM
Old 09-12-2005
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 Smilie
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

moving and renaming multiple files

Greetings, I know i can use the mv command to move and rename one file. How can I do this with multiple files? example pic01.bmp to pic0001.bmp how can i perform this function on an entire directory of sequential files and keep them in sequence? Hints, suggestions are most welcome:) ... (1 Reply)
Discussion started by: rocinante
1 Replies

2. Shell Programming and Scripting

Moving multiple files and renaming them on the fly

Hi All, Being new to scripting I am facing a new situation. We have an application that generates a file lets say dumpfile for each user under the users home directory when they execute the application. This is quite a huge file and imagine having that for over 40 users on a daily basis. The... (1 Reply)
Discussion started by: daemongk
1 Replies

3. Shell Programming and Scripting

using mv command for moving multiple files in a folder

Hi, I have a requirement where I need to move Bunch of folders containing multiple files to another archive location. i want to use mv command .I am thinking when we use mv command to move directory does it create directory 1st and then move all the files ? e.g source... (4 Replies)
Discussion started by: rkmbcbs
4 Replies

4. UNIX for Dummies Questions & Answers

Need help in moving files recursively

Hi, I have d1,d2,d3 directories / /home/abc/d1 /home/abc/d2 /home/abc/d3 d1,d2 and d3 also have subdirctories. d1-->d11-->d12 d2-->d22-->d23 d3-->d33-->d34 All these directories have files like date_filename.txt so I want to find the files recusively for a particular date from... (1 Reply)
Discussion started by: jagadish_gaddam
1 Replies

5. UNIX for Dummies Questions & Answers

Zip multiple files recursively via UNIX

Hello, After searching, I didn't find any answer to execute my task. Her what I want to achieve on my MAC : Create a ZIP file (not tar.gz or other) from a file I want the ZIP created to have the name of the original file I want to do this on multiple files (314 exactly) So at the end the... (3 Replies)
Discussion started by: anou
3 Replies

6. UNIX for Advanced & Expert Users

Moving multiple files based on the pattern

I want to search for a particular file name patterns and move them to a specific folder, is it possible to do it with awk or sed? (1 Reply)
Discussion started by: rudoraj
1 Replies

7. Shell Programming and Scripting

[SOLVED] moving multiple files? mv

HI I have a list of files that are incorrectely names and I need to move them to new name .. I tried few things that has not worked so far can you help ? I need to rename all thes eifle ( tere are over 100 ) xldn0357bap.orig.new xldn0389bap.orig.new xldn0439bap.orig.new... (12 Replies)
Discussion started by: mnassiri
12 Replies

8. Shell Programming and Scripting

Moving and renaming multiple files in a directory

Hi. I am trying to automate the movement and renaming of a number of files in a directory. I am using the 'mv' command as I do not have access to 'rename'. I have the following scripted FILES=$(ls /transfer/move/sys/mail/20130123/) if ; then for i in ${FILES} ; do mv... (4 Replies)
Discussion started by: jimbojames
4 Replies

9. UNIX for Dummies Questions & Answers

Moving multiple datestamped files (Linux)

Hello all, I'm writing a script that will allow me to move files into a sub-directory for archiving. These files, specifically, are output files that result at the end of a process. The issue I'm having is that while moving files from one place to another is relatively an easy task, grabbing... (2 Replies)
Discussion started by: galileo1
2 Replies

10. Shell Programming and Scripting

Search/Replace in multiple files recursively

Hi there, I am using AIX and trying to search and replace a string with another string in multiple files in different directories. I wanted to search replace in steps so I don't change all of the instance anywhere in the server at once, minimizing impact. STEP 1: -------- I first searched... (5 Replies)
Discussion started by: zaino22
5 Replies
CPIO(1) 						    BSD General Commands Manual 						   CPIO(1)

NAME
cpio -- copy file archives in and out SYNOPSIS
cpio -o [-AaBcLvZz] [-C bytes] [-F archive] [-H format] [-O archive] < name-list [> archive] cpio -i [-6BbcdfmrSstuvZz] [-C bytes] [-E file] [-F archive] [-H format] [-I archive] [pattern ...] [< archive] cpio -p [-adLlmuv] destination-directory < name-list DESCRIPTION
The cpio command copies files to and from a cpio archive. If the archive is of the form: [[user@]host:]file then the archive will be pro- cessed using rmt(8). The options are as follows: -o, --create Create an archive. Reads the list of files to store in the archive from standard input, and writes the archive on standard output. -a, --reset-access-time Reset the access times on files that have been copied to the archive. -A, --append Append to the specified archive. -B Set block size of output to 5120 bytes. -c Use ASCII format for cpio header for portability. -C bytes Set the block size of output to bytes. -F archive -O archive Use the specified file name as the archive to write to. -H format Write the archive in the specified format. Recognized formats are: bcpio Old binary cpio format. cpio Old octal character cpio format. sv4cpio SVR4 hex cpio format. tar Old tar format. ustar POSIX ustar format. -L Follow symbolic links. -v Be verbose about operations. List filenames as they are written to the archive. --xz Compress/decompress archive using xz(1) format. -Z Compress archive using compress(1) format. -z Compress/decompress archive using gzip(1) format. -i, --extract Restore files from an archive. Reads the archive file from standard input and extracts files matching the patterns that were speci- fied on the command line. -b Do byte and word swapping after reading in data from the archive, for restoring archives created on systems with a different byte order. -B Set the block size of the archive being read to 5120 bytes. -c Expect the archive headers to be in ASCII format. -C bytes Read archive written with a block size of bytes. -d, --make-directories Create any intermediate directories as needed during restore. -E file, --pattern-file file Read list of file name patterns to extract or list from file. -f, --nonmatching Restore all files except those matching the patterns given on the command line. -F archive, --file archive -I archive Use the specified file as the input for the archive. -H format, --format format Read an archive of the specified format. Recognized formats are: bcpio Old binary cpio format. cpio Old octal character cpio format. sv4cpio SVR4 hex cpio format. tar Old tar format. ustar POSIX ustar format. -m Restore modification times on files. -r, --rename Rename restored files interactively. -s Swap bytes after reading data from the archive. -S, --swap-halfwords Swap words after reading data from the archive. -t, --list Only list the contents of the archive, no files or directories will be created. -u, --unconditional Overwrite files even when the file in the archive is older than the one that will be overwritten. -v, --verbose Be verbose about operations. List filenames as they are copied in from the archive. -z Uncompress archive using gzip(1) format. -Z Uncompress archive using compress(1) format. -6 Process old-style cpio format archives. -p, --pass-through Copy files from one location to another in a single pass. The list of files to copy are read from standard input and written out to a directory relative to the specified directory argument. -a Reset the access times on files that have been copied. -d Create any intermediate directories as needed to write the files at the new location. -l, --link When possible, link files rather than creating an extra copy. -L, --dereference Follow symbolic links. -m, --preserve-modification-time Restore modification times on files. -u, --unconditional Overwrite files even when the original file being copied is older than the one that will be overwritten. -v, --verbose Be verbose about operations. List filenames as they are copied. --force-local Do not interpret filenames that contain a ':' as remote files. --insecure Normally cpio ignores filenames that contain ``..'' as a path component. With this option, files that contain ``..'' can be processed. EXIT STATUS
cpio will exit with one of the following values: 0 All files were processed successfully. 1 An error occurred. Whenever cpio cannot create a file or a link when extracting an archive or cannot find a file while writing an archive, or cannot preserve the user ID, group ID, file mode, or access and modification times when the -p option is specified, a diagnostic message is written to stan- dard error and a non-zero exit value will be returned, but processing will continue. In the case where cpio cannot create a link to a file, cpio will not create a second copy of the file. If the extraction of a file from an archive is prematurely terminated by a signal or error, cpio may have only partially extracted the file the user wanted. Additionally, the file modes of extracted files and directories may have incorrect file bits, and the modification and access times may be wrong. If the creation of an archive is prematurely terminated by a signal or error, cpio may have only partially created the archive which may vio- late the specific archive format specification. SEE ALSO
pax(1), tar(1) AUTHORS
Keith Muller at the University of California, San Diego. BUGS
The -s and -S options are currently not implemented. BSD
June 18, 2011 BSD
All times are GMT -4. The time now is 10:41 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy