Now, I have to keep the files 1 and 2 and backup the files 3 and 4 into other dir.
I have list of files in a dir and I have list of file names in a file xx123. I need to find files present in dir and not in xx123 and vice versa. is there any short way to do this?
Thank you. The command is not exactly fetching the old files. Check the below,
$ ll XX*
-rw-r--r-- 1 fp015362 user 0 Oct 5 19:45 XX111_20101005010203.dat
-rw-r--r-- 1 fp015362 user 0 Oct 5 19:44 XX121_20101003010101.dat
-rw-r--r-- 1 fp015362 user 0 Oct 5 19:44 XX122_20101002010101.dat
-rw-r--r-- 1 fp015362 user 0 Oct 5 19:44 XX123_20101004010101.dat
-rw-r--r-- 1 fp015362 user 0 Oct 5 19:44 XX124_20101004010201.dat
$ ls XX*.dat | sort -t_ -k2nr |sed -n '3,$p'
XX123_20101004010101.dat
XX121_20101003010101.dat
XX122_20101002010101.dat
---------- Post updated at 05:53 AM ---------- Previous update was at 05:48 AM ----------
I have used ll command just to show the available files. Pls check the next command to find the old files. latest files will be fetched using the date in the file name (time part needs to be ignored).