find, mv and create unknown parent & subfolders


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers find, mv and create unknown parent & subfolders
# 1  
Old 07-15-2008
find, mv and create unknown parent & subfolders

I searched the forum rather thoroughly but still could not find the answer. Hopefully the solution is right under my nose.

Here what I need to do, move older data to a Archive folder that is 18 months old and older.

I would like to use the following command,

find departmentx/* -mtime 530 -exec mv {} Archive/departmentx/{} \;

of course the problem is, there are some subfolders & parent folders within this search that will need to be created so the files can be moved into them, otherwise I just get errors.

Any Ideas?
thanks in advance
# 2  
Old 07-15-2008
Why not cpio to archive/dept; then rm? you keep the directory structure in that case

Last edited by vbe; 07-15-2008 at 01:53 PM.. Reason: correcting my franglish...
# 3  
Old 07-15-2008
That is one option, but if possible I was hoping to do it in one step. Mainly due to limited down time this server has between shifts, and the size of each departments folders.
(They like their data, think its like a comfort blanket or something)
# 4  
Old 07-15-2008
I dont see where there is downtime issue...

What I do if you have size concern is as you are trying, recreate a archive structure, but I then after a while archive what I find there in files I cal .arc (using cpio...) and compress the lot, IF someone what to see the content, he will have to use a script I called cpiozipdir which shows him the content (and directory structure)...
# 5  
Old 07-15-2008
I like to be extra extra careful when messing with users files like this. Instead of trying to do it using a one line find command why not take the time to write a perl script that does some error checking along the way. Also, realise that find command you're using will also return directories so if you're going to do it that way either add a -type f switch or make sure what you do in the end can process directories.
# 6  
Old 07-15-2008
I think I will have to go that way (perl that is)

Any way, thanks for your responses guys
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Find for files within a list of subfolders

Helo Is there a better way to search within a list of subfolders : A_START_PATH="/data_1/data_2" # # dir2, dir3, dir6, ..... dir59 exists # A_LIST="$A_START_PATH/dir1 $A_START_PATH/dir4 $A_START_PATH/dir5" find "$A_LIST" -type f -name"*.txt" Now searching for all files in any subdirs... (2 Replies)
Discussion started by: jcdole
2 Replies

2. Shell Programming and Scripting

Bulk find in UNIX at unknown dir location

Dear All, I have a file which is having a number my_file.csv 032001031 100509001 203001165 there are many more about 5000. I have a path in unix /my_path/my_loc/DEV/RPD10/CPD25/WFM/RK_WFM/OUT/*/ where i will have a file like CPD25_203001165.pdf CPD25_100509001.pdf... (4 Replies)
Discussion started by: yadavricky
4 Replies

3. Emergency UNIX and Linux Support

Script for deleting orphan ids & unknown gecos

The AIX servers that I am working on have been identified as having orphaned user ids & improper gecos for some user ids. Can someone help me with a script to delete the user ids if the orphaned ids are provided in a text file. The home directory set up for the user ids happen to be the... (1 Reply)
Discussion started by: ggayathri
1 Replies

4. Shell Programming and Scripting

Find & replace --> create a new file

Hi All, I have a unix shell script file as below. My task is a)to replace 248 to 350 and need to create a new file as BW3_350.sh b)to replace 248 to 380 and need to create a new file as BW3_380.sh c)to replace 248 to 320 and need to create a new file as BW3_320.sh there is no... (6 Replies)
Discussion started by: karthi_mrkg
6 Replies

5. Shell Programming and Scripting

Shell script delete log files from folder & subfolders on space usage

Hi, I am trying to write a shell script to delete logs generate by db when space in the folder reaches 70%. i am getting space values from db, find the files at OS and remove them by using a cron job runs every 5minutes. I have to keep the latest 5 files at any time, my problem is that log files... (3 Replies)
Discussion started by: saha
3 Replies

6. Shell Programming and Scripting

full path of a file situated either in parent's dir. or parent's parent dir. so on...

hi experts(novice people can stay away as it is no child's game), i am developing a script which works like recycle bin of windows. the problem i am facing is that when ever i am trying to delete a file which is situated in parent directory or parent's parent directory i am unable to... (1 Reply)
Discussion started by: yahoo!
1 Replies

7. UNIX for Advanced & Expert Users

find size of folders and its subfolders with the Owner details

HI, I have the following command that shows me the total size of folders and subfolders : du -hs *| sort -n result: 1.0M sandeep 1.4G sandy 1.4M important 1.6M files but I will need to know the size of folders and its subfolders( not size of individual files though)... (5 Replies)
Discussion started by: bsandeep_80
5 Replies

8. UNIX for Dummies Questions & Answers

How to find files whose case is unknown

Hello experts, can you kindly tell me how I can look for a file in unix whose name may contain upper or lowercase letters? E.g. If I know the file contains the name netcool but unsure if its NETCOOL or netcool? Thanks :) (3 Replies)
Discussion started by: mitkapadia
3 Replies

9. UNIX for Dummies Questions & Answers

Basic Q: getting list of all files of type within folder & subfolders

A painfully rudimentary UNIX question for somebody. I've been puzzling over this for the last hour but can't find the right command. I'm simply trying to get a list of all files - and their full paths - within a folder & subfolders which have extension .php and .js. That's it! No amount of... (1 Reply)
Discussion started by: AtomicPenguin
1 Replies

10. Shell Programming and Scripting

How to create folders/subfolders using shellscript

Hi, Can any one help me how to create folders using shellscript.My requirement is: FolderName: Main/Main1 :Main/Main2 :Main/Main3 underSubFolder : Main1/A :Main1/B :Main1/C underSubfolder: A/A1 ... (2 Replies)
Discussion started by: ram2s2001
2 Replies
Login or Register to Ask a Question