finding and copying files !


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers finding and copying files !
# 1  
Old 06-14-2005
finding and copying files !

Hi ,
I have a question relating to finding and copying files.

i need to find the .pdf files from the specified directory which has subdirectories too. I only need .pdf files and not the directories and need to copy those files into my current directory.

copy files from : /home/kit/1/abc.pdf
/home/kit/2/aa.pdf
/home/kit/3/aaa.pdf


to my directory : /sample/abc.pdf
/sample/aa.pdf
/sample/aaa.pdf

can anyone help me to write the script.
Thanks in advance,
bregoty
# 2  
Old 06-14-2005
Try this.

Code:
find /home/kit/ -name '*.pdf' -exec cp /sample/ {} \;

Vino
# 3  
Old 06-14-2005
Data finding and copying files!

It is not working . I tried with different options as well as urs.

Sometimes it is giving the /sample is not a directory and sometimes don't have access of copying and sometimes you should use "-R" option .

I have changed permission(rwx) of sample directory

i don't have no clue ?

thanks,
bregoty
# 4  
Old 06-14-2005
Try this.

Code:
find /home/kit -name '*.pdf' | while read file; do cp $file /sample/ ; done


Vino
# 5  
Old 06-14-2005
To /sample
Code:
find /home/kit -name '*.pdf' -exec cp {} /sample \;

To current dir:
Code:
find /home/kit -name '*.pdf' -exec cp {} . \;

# 6  
Old 06-14-2005
This is working fine.

Thanks.
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Need help in finding and copying list of files using bash shell script

Dear All, I have a situation where I want to copy some files of type .txt. These files are o/p from one program. Some of the files are named as fileName .txt instead of fileName.txt after fileName by mistake I have specified "space". Now I want to move these files as follows. mv fileName*... (13 Replies)
Discussion started by: linuxUser_
13 Replies

2. UNIX for Advanced & Expert Users

Challenges in finding and copying the block

Hi, I have a below challenging task where iam unable to find the block and copy the same into a file. I tried my luck,howver iam unable to reach the first and second step..Can anyone help me with a clue or with the commands so that i can give a try. 1. search the <number>9966993366</number>... (2 Replies)
Discussion started by: cskumar
2 Replies

3. UNIX for Dummies Questions & Answers

finding, copying, assembling

Hi everybody, I've been running some analyses, the results of which have been stored in a sequential manner with a directory structure like step0, step1, step2, ... for iterations 0-2, for example. Each iteration contains several nested folders, with three pieces of information I need. I need to... (1 Reply)
Discussion started by: JDenton
1 Replies

4. UNIX for Dummies Questions & Answers

Finding duplicates then copying, almost there, maybe?

Hi everyone. I'm trying to help my wife with a project, she has exported 200 images from many different folders, unfortunately there was a problem with the export and I need to find the master versions so that she doesn't have to go through and select them again. I need to: For each image in... (2 Replies)
Discussion started by: Rhinoskin
2 Replies

5. Shell Programming and Scripting

Files copying - [ Listed files alone. ] - Shell script

Hi All, I am doing this for svn patch making. I got the list of files to make the patch. I have the list in a file with path of all the files. To Do From Directory : /myproject/MainDir To Directory : /myproject/data List of files need to copy is in the file: /myproject/filesList.txt ... (4 Replies)
Discussion started by: linuxadmin
4 Replies

6. Shell Programming and Scripting

Finding & Copying files

Hello :) can someone please help me with this task: I am in the shell, in folder "Main" below the folder Main are sub folders: "sourceA", "Source B", and "target" in sourceA and source B are files, and in folder "Main" is a textfile, with filenames, one filename per line. I need a... (4 Replies)
Discussion started by: Y-T
4 Replies

7. UNIX for Advanced & Expert Users

copying of files by userB, dir & files owned by userA

I am userB and have a dir /temp1 This dir is owned by me. How do I recursively copy files from another users's dir userA? I need to preserve the original user who created files, original group information, original create date, mod date etc. I tried cp -pr /home/userA/* . ... (2 Replies)
Discussion started by: Hangman2
2 Replies

8. UNIX for Dummies Questions & Answers

Finding and Copying Email

I have to create a bash script that will find Feedback emails and copy them to a labFeedback folder in my mail directory. I have an idea in my head on what commands can be used for this (find obviously among them). However, I have no idea where to start. I'm not sure what info needs to be given,... (1 Reply)
Discussion started by: Joesgrrrl
1 Replies

9. Shell Programming and Scripting

script for Finding files in a folder and copying to another folder

Hi all, I have a folder '/samplefolder' in which i have some files like data0.txt, data1.txt and data2.txt. I have to search the folder for existence of the file data0.txt first and if found have to copy it to some other file; next i have to search the folder for existence of file... (5 Replies)
Discussion started by: satish2712
5 Replies

10. Shell Programming and Scripting

finding duplicate files by size and finding pattern matching and its count

Hi, I have a challenging task,in which i have to find the duplicate files by its name and size,then i need to take anyone of the file.Then i need to open the file and find for more than one pattern and count of that pattern. Note:These are the samples of two files,but i can have more... (2 Replies)
Discussion started by: jerome Sukumar
2 Replies
Login or Register to Ask a Question