AIXThis forum is for the discussion of IBM AIX.
eserver and other IBM related questions are also on topic.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
I am trying to move files older than 30 days without moving files in the lower directories. My file structure is as follows...
Dir1-
|Dir2
|Dir3
I want to move all files older than 30days from Dir1 to Dir2. Here is what I have...
find /Dir1 -type f -mtime +30 -exec mv {} Dir2 \; ( but this moves all files in other subdirectories.)
You can also skip find in the start of your search
ls -F /dir1 | grep -v /
#this will only return regular files not dirs from the dir1 then add
| xargs -I {} find ./{} -mtime +30 | xargs -I {} mv {} /dir2
it is not pretty but I think this will work... a Perl script or ksh would be cleaner but I have not done many jobs like this in a long time...
the only item that I am not sure on is the “./{}” please check on this…
if it does not work like you want you might do a cd /dir1 then use ls ... find . that will make the ./{} easer to debug... -KJ
Well pattern matching comes to mind. I think you need to research metacharacters
I think you are looking for:
find / | grep -v "^/tmp|^/tm2|^/tmp3"
but am not sure. There are so many variations, that it is to hard to know exactly.
If the sub-dir's can vary you can not word match but will need to string ... bla bla
also you can also always find / | grep ^/tmp | grep ^... as many times as you like... It is not as clean but always works if you test it thourally...
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.