Copying files based on a pattern


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Copying files based on a pattern
# 1  
Old 06-26-2012
Copying files based on a pattern

Hi All,

I need to find and list the last 5 days files in that exact name with "MIM" and copy to another directory.
please help me in this there is around 30000 files
Thanks
Murali

Last edited by radoulov; 06-26-2012 at 11:59 AM.. Reason: title fixed
# 2  
Old 06-26-2012
Let's start with finding the files. This finds filee with the EXACT name "MIM". I'm not sure that was what you meant. I assume the MIM files are in some directory tree, let's call it "start"
Code:
find /start -name 'MIM' -exec ls {} \;

# 3  
Old 06-26-2012
Thanks for your reply

I have excuted the below command as below and got below error
Code:
find /start -name 'MIM_110' -exec ls {} \;
find: 0652-019 The status on /start is not valid.

I need these files copy to anohter palce

please help me in this,this is bit urgent

Last edited by radoulov; 06-26-2012 at 11:51 AM..
# 4  
Old 06-26-2012
/start means give the path, where you want to search
# 5  
Old 06-26-2012
yes i given,not listing any files

---------- Post updated at 09:54 AM ---------- Previous update was at 09:49 AM ----------

I tried as below,its not copying

Code:
find /path -name 'MIM_110' -exec cp -r  {} /tmp/MIM \;

Moderator's Comments:
Mod Comment Video tutorial on how to use code tags in The UNIX and Linux Forums.
# 6  
Old 06-26-2012
Where are the files located - what is the FULL name of one MIM file:
Code:
# short name 
MIM
# full name - the directory names are pretend, they will be different on your machine
/somedirectory/data/Sunday/MIM

If they are all over everywhere use / the root directory.
Code:
find / -name MIM

# 7  
Old 06-26-2012
The files are in the one directry only but the file name is lengthy as below and diffrent each other

these files format as below

MIM_110_00000000023_8533.txt.00000000034.txt
MIM_110_00000000024_8533.txt.00000000035.txt
.
.
.
.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Extract date from files based on file pattern

I want to extract dates from the files and i have different types of files with pattern. I have list file with the patterns and want to date extract based on it in a sh script Files in the directory : file1_20160101.txt file2_20160101_abc.txt filexyz20160101.txt list file with... (2 Replies)
Discussion started by: lijjumathew
2 Replies

2. Shell Programming and Scripting

Copying files to directories based on first 6 character

guys, i did create a script but its too long, though it function the same. # cat nightlyscan.sh #!/usr/ksh deyt=`date +"%Y-%m-%d"` for i in `ls -lrt|grep $deyt|awk '{print $9}'` do cp -f $i /S1/Sophos/logger/ done # but i did not paste it all. this is the desired. (9 Replies)
Discussion started by: kenshinhimura
9 Replies

3. Shell Programming and Scripting

Finding all files based on pattern

Hi All, I need to find all files in a directory which are containing specific pattern. Thing is that file name should not consider if pattern is only in commented area. all contents which are under /* */ are commented all lines which are starting with -- or if -- is a part of some sentence... (13 Replies)
Discussion started by: Lakshman_Gupta
13 Replies

4. Shell Programming and Scripting

Moving old files based on pattern

Hi all I am trying to loop through a directory of files using a given search pattern. some of the files will be duplicated due to the pattern, but of the duplicate files i wanted to move the older files to another location. Is there any straightforward way of doing this ? One of ways I... (1 Reply)
Discussion started by: sthapa
1 Replies

5. Shell Programming and Scripting

Copying files with a specific pattern

Hi All I am trying to copy files from one location to another and given below are some sample ones: aaa_bbb_ccc_ddd_cost_code_20140330.gz aaa_bbb_ccc_ddd_revenue_zone_20140329.gz aaa_bbb_ccc_ddd_benefit_extract_20140330.csv.gz aaa_bbb_ccc_ddd_profit_zone_20150509.csv.gz... (17 Replies)
Discussion started by: swasid
17 Replies

6. Shell Programming and Scripting

Combine 3 files based on a pattern

HI, I have 3 files that contain the following information (sql output from Oracle database stored in a txt file): File1.txt : alter table "SYS"."INT_COST_PRICE" enable row movement; alter table "SYS"."INT_SOH" enable row movement; alter table "SYSMAN"."XX_ACI_SKURTP" enable row movement;... (6 Replies)
Discussion started by: rparavastu
6 Replies

7. UNIX for Dummies Questions & Answers

List only files based on a pattern

Hi Gurus, I need to list only the files with out certain extension. For eg from the following list of files: I need to only list: Thanks Shash (7 Replies)
Discussion started by: shash
7 Replies

8. 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

9. UNIX for Dummies Questions & Answers

copying a pattern of files in one directory into other with new pattern names...

Hi, I have to copy a set of files abc* in /path/ to /path1/ as abc*_bkp. The list of files appear as follows in /path/: abc1 xyszd abc2 re2345 abcx .. . abcxyz I have to copy them (abc* files only) into /path1/ as: abc1_bkp abc2_bkp abcx_bkp .. . (6 Replies)
Discussion started by: new_learner
6 Replies

10. UNIX for Dummies Questions & Answers

copying files from one location to another based on a list

I have a text list of about 3,000 file names (image files), which exist on a server and that I want to copy over to another location. I understand the Unix cp code, but what's the string to have it copy multiple files based on an external list? Many thanks! (4 Replies)
Discussion started by: rebornhonest
4 Replies
Login or Register to Ask a Question