extract files from subdirectories to another dir
hi...
i'm wondering if cp has this feature : i want to extract *.txt files in a directory with several subdirectories containing *.txt files ie. /usr/options/textfiles/aug25/aug25.txt /usr/options/textfiles/aug26/aug26.txt /usr/options/textfiles/aug27/aug28.txt /usr/options/textfiles/aug28/aug27.txt /usr/options/textfiles/dates.txt i need to extract and copy all *.txt files in /usr/options/textfiles/ into one directory, ie hav all the *.txt files extracted from their folders the cp -r copies everthing (subfolders and files).. is there a way just to extract the files? i'm sorta want to do this.. find /usr/options/textfiles | grep .txt copy (the result of find) to /usr/text/ thanks! |
A simple for loop will do it:
Code:
for FILE in `find /usr/options/textfiles -type f` The "cp -p" says to copy it with the same modification date, permissions, ownership and group as the original. FILE is an abitrary variable name which is later referenced as $FILE. You could use FRED and $FRED instead if you preferred - the name doesn't matter so long as it isn't a reserverd variable like PATH. |
All times are GMT -5. The time now is 06:49 PM. |