Hi Experts,
I want to write a script, based upon the following requirement
1) I am having 5 application
HTML Code:
$ cd logs
$ ls -l
drwxr-xr-x 2 natraj nat 5.0K Sep 20 10:25 one
drwxr-xr-x 2 natraj nat 5.0K Sep 20 10:39 two
drwxr-xr-x 2 natraj nat 1.5K Sep 20 10:58 three
drwxr-xr-x 2 natraj nat 7.5K Sep 20 11:06 four
drwxr-xr-x 2 natraj nat 2.0K Sep 20 11:48 five
2) Each application having log files
HTML Code:
$ cd one
$ ls -l
-rw-r--r-- 1 natraj nat 11K Sep 15 15:31 y.log.150911
-rw-r--r-- 1 natraj nat 439K Sep 15 16:05 x.log.150911
-rw-r--r-- 1 natraj nat 15K Sep 16 12:08 y.log
-rw-r--r-- 1 natraj nat 470K Sep 16 17:14 x.log.160911
-rw-r--r-- 1 natraj nat 58K Sep 19 18:40 x.log
3) I want only last 2 days log files , remaning need to zip and move to archive foldeer (logs_archive).
4) Want to move the logs to archive folder with same directory name , if same directory not exist means need to create and then move the logs file.
5) Finally it should be like as below
HTML Code:
$ cd /logs_archive/one
$ ls -l
-rw-r--r-- 1 natraj nat 11K Sep 15 15:31 y.log.150911.z
-rw-r--r-- 1 natraj nat 439K Sep 15 16:05 x.log.150911.z
-rw-r--r-- 1 natraj nat 15K Sep 16 12:08 y.log.z
-rw-r--r-- 1 natraj nat 470K Sep 16 17:14 x.log.160911.z
help me to solve it out
. . . .
Thanks in advance . . . .
---------- Post updated at 05:52 AM ---------- Previous update was at 02:44 AM ----------
hi friends help me to write a script for moving the files . . . . .