coping files, need to exclude certain files


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting coping files, need to exclude certain files
# 1  
Old 05-26-2009
coping files, need to exclude certain files

I have two directories that contain data files. I would like to create a script that would copy all data files (*.dbf) from these directories to another location, except for 4 specific files.

How do I exclude those files from my cp command?
# 2  
Old 05-26-2009
Doing a google once...... given me this...

Code:
find ./ ! -name '*.svn' | xargs -i cp {} dest_dir

will copy all files (excluding *.snv files).
# 3  
Old 05-26-2009
The problem is that the files I want to exclude are also *.dbf files
# 4  
Old 05-26-2009
Code:
find . ! -name "a.dat" ! -name "rem.txt" -name "*.dat" |xargs  -i  cp {} DEST


When i executed the above command , all files except a.dat file copied to the DEST folder. Although (a.dat fall under *.dat , find still excludes tht file).

In your case exclude all the 4 files , by putting their filenames in the commnad above and try.
# 5  
Old 05-26-2009
Thank you panyam, that worked perfectly
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Error files count while coping files from source to destination locaton as well count success full

hi All, Any one answer my requirement. I have source location src_dir="/home/oracle/arun/IRMS-CM" My Target location dest_dir="/home/oracle/arun/LiveLink/IRMS-CM/$dc/$pc/$ct" my source text files check with below example.text file content $fn "\t" $dc "\t" $pc "\t" ... (3 Replies)
Discussion started by: sravanreddy
3 Replies

2. Shell Programming and Scripting

Exclude files in ls

Hi, I need to exlucde the files which are present in exclude.txt from a directory exlcude.txt AUZ.txt AUZ.chk NZ.txt NZ.chk tried with below code but not working ls -ltr | grep -v `cat exclude.lst` (9 Replies)
Discussion started by: rohit_shinez
9 Replies

3. Shell Programming and Scripting

Need to exclude .NFSxxx files in clear old files batch script

I am new to Shell Scripting and need some help. The following batch job has been failing for me due to the .nfsxxx files in use. I need to know how to modify the following script to exclude the .nfsxxx files so this batch job will not fail on me. I have done lots of googling and keep coming back... (2 Replies)
Discussion started by: kimberlyg2007
2 Replies

4. Shell Programming and Scripting

Delete all files but exclude some files

Hi, I have a software install in a directory, says "/opt/tibco". If I want to remove all the things in this directory and its sub-directories, but exclude all log files (*.log in different directories) and keep empty directories exist. What should my command look like? I have no idea on how... (2 Replies)
Discussion started by: dirkaulo
2 Replies

5. Shell Programming and Scripting

Coping files that containing 2010

I want to use the find command to copy files that contain 2012 from one directory to another. I tried find /Volumes/movies1 -name "*.2012.*" -exec cp -nRv "{}" /Volumes/pdrive/ \; (2 Replies)
Discussion started by: codecaine
2 Replies

6. UNIX for Dummies Questions & Answers

coping files from unix to windows

hey all, i have a unix computer and a windows os computer connected in the same local network i want to copy the etc folder to the windows computer so if my unix computer's hard disk rashes i can restore it from my windows computer. my first problem is i'm kinda lame with unix...i know... (3 Replies)
Discussion started by: shwinky
3 Replies

7. UNIX for Dummies Questions & Answers

Coping Files for a specific date range

Hi, we have file name appended by date in yymmdd format .. ex: abc090101.dat I need to copy all the files between abc090101 to abc090331.. could you plz help me.. Thanks. (1 Reply)
Discussion started by: kolariya4u
1 Replies

8. UNIX for Dummies Questions & Answers

list the files but exclude the files in subdirectories

If I execute the command "ls -l /export/home/abcde/dev/proj/code/* | awk -F' ' '{print $9}' | cut -d'/' -f6-8" it will list all the files in /export/home/abcde/dev/proj/code/ directory as well as the files in subdirectories also proj/code/test.sh proj/code/test1.c proj/code/unix... (8 Replies)
Discussion started by: shyjuezy
8 Replies

9. Shell Programming and Scripting

Coping files from server to local

This is my first post, so first I'd like to say hello to everyone. Here's the issue I'm having...I run a macro against multiple log files every morning. The procedure is sort of time consuming. I have to log into the box where there are stored, then ftp/download them to my local drive using... (3 Replies)
Discussion started by: jhofilena
3 Replies

10. UNIX for Dummies Questions & Answers

coping all files from a directory

Hello, i have a directory;say /home/pavi i has some files and every day files keep adding to it. i am writing a shell script which copies all the files from this directory to another.say /home/tom/tmp how do i copy all the files from /home/pavi to /home/tom/tmp all the files in the... (1 Reply)
Discussion started by: pavan_test
1 Replies
Login or Register to Ask a Question