File move and deletion in Unix


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting File move and deletion in Unix
# 1  
Old 02-23-2010
File move and deletion in Unix

I have 63,000 files in a directory [per one day]

I want to move all the 20100219 day files to /target directory

I used
Code:
$mv *20100219* /target
too many arguments

Then i used
Code:
$find . -name "*.txt"|grep "20100221"|xargs -I '{}' mv {} /target

It will take more than 3 hours to move all the files

Is there any way to optimise the command where it will take less time

Same for removing

Code:
$find . -name "*.txt"|grep "20100221"|xargs rm -rf

[For 60,000 files it's taking 20 minutes ]

How to reduce the time for both command . or is there any other way to do this.

Please let me know

Last edited by pludi; 02-23-2010 at 03:34 AM.. Reason: code tags, please...
# 2  
Old 02-23-2010
You might get a bit of speed using
Code:
find . -type f -name '*20100219*.txt' -exec mv {} /target \;

or, if you have GNU find
Code:
find . -type f -name '*20100219*.txt' -exec mv {} /target \+

But in the long run, it's probably better to change whatever application that's writing these files to use a more manageable structure.
# 3  
Old 02-23-2010
MySQL

You are two pipes to achieve this .It may slow down the process.

Without the pipe we can achieve,

Code:
find . -maxdepth 1 -iname "*20100221*.txt" -exec mv {} target \;

Here I used the maxdepth option.Because If the target folder is in the same directory then it will through error like,

Code:
 mv: `./target/a20100221b.txt' and `target/a20100221b.txt' are the same file

So better we can use maxdepth.

Last edited by pludi; 02-23-2010 at 03:57 AM.. Reason: code tags, please...
# 4  
Old 02-23-2010
move operation.

mv command itself we can do that one. command is,
Code:
mv *date*

Another way,
Code:
find . -type f -iname '*20100111*.txt' -exec mv {} /target \;

Those ways are give some speed to move command.

Last edited by pludi; 02-23-2010 at 03:58 AM.. Reason: code tags, please...
# 5  
Old 02-23-2010
Thanks to all of u...
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Deletion of list of user based on a text file In LDAP UNIX server

Dear All, It would be really nice, if you could help me to write a script for deletion of list of user( more than 15000 users) stored in a file and sorted by email address( i need deletion of only a particular type of mail address). Is the any script to write and take the file as input and... (3 Replies)
Discussion started by: Chand
3 Replies

2. Shell Programming and Scripting

Need help to move .csv file from UNIX path to window c: shared drive

Hi Guys, I need to move myfile.csv file from unix path(\oracle_home) to window c:\ shared drive h:\. Thanks in advance! Regards, Lakshman (1 Reply)
Discussion started by: lakshmanraok117
1 Replies

3. UNIX for Dummies Questions & Answers

Move a .zip file to a unix system in .rar format

Hi all, need help here in moving a .zip file into a suse system and want it to be in .rar format. How can i do this? (1 Reply)
Discussion started by: mena
1 Replies

4. Shell Programming and Scripting

Batch job in unix server to move the pdf file from unix to windows.

Hi Experts, I have a requirement where i need to setup a batch job which runs everymonth and move the pdf files from unix server to windows servers. Could some body provide the inputs for this. and also please provide the inputs on how to map the network dirve in the unix like that... (1 Reply)
Discussion started by: ger199901
1 Replies

5. Shell Programming and Scripting

FTPS Script to move a file to Unix Folder

Dear Experts, I need to connect to a FTPS Server and move the files from FTPS folder "/SAP/Out" to Unix directory "/SAP/In". I need to run this script on Unix directory...Script should get the files from FTPS folder and place that in specified Unix Directory. Thanks In Advance. (1 Reply)
Discussion started by: phani333
1 Replies

6. Shell Programming and Scripting

File content deletion

Hi Everyone, There are certain files under a folder 'ABC' and the entries for these files are there in another file(fname) under a different folder 'XYZ'. I want to compare the folder contents(ABC) with the file(fname) contents and delete the mismatching / non-existing ones from the file,... (4 Replies)
Discussion started by: swasid
4 Replies

7. Shell Programming and Scripting

want file to regenerate after deletion

I looked into the sticky bit, but I think, if possible, that I would prefer to have the file recreate itself after deletion. The file is several directories deep, and from time to time the top level directory will be trashed. I need the file to recreate after this. Is it possible to perhaps... (13 Replies)
Discussion started by: glev2005
13 Replies

8. Shell Programming and Scripting

Prompting for file deletion?

I got help in another forum but now I need further help so I figured I'd ask here. I had to write a script to delete certain filenames of certain size. I got this far.. find . -size 110c -name "*testing*" -print | xargs -n 1 rm -i It finds the correct files, but the prompts to delete are all... (2 Replies)
Discussion started by: NycUnxer
2 Replies

9. UNIX for Dummies Questions & Answers

large file deletion

OS: Solaris 8 I deleted a large file (around 13 Gigs) from my system. But the output of df -k remains the same. The capacity % is constant. However one strange thing is happening- My available space is decreasing, my used space in increasing (The opposite should happen). This is happening... (2 Replies)
Discussion started by: run_time_error
2 Replies

10. UNIX for Dummies Questions & Answers

Deletion of File in Unix

Hi there guys. I'm quite new in using unix and just recently experienced missing file problem. Someone accidentally or likely intentionally deleted one specific folders that contains important file. Now my question is, can any other user aside from root can do such action? Please help. ... (2 Replies)
Discussion started by: rhomel101
2 Replies
Login or Register to Ask a Question