I have below two situations to handle,
1. I have list of files with file names having date&time. I have to backup to old date files. say I have below files in a directory,
Now, I have to keep the files 1 and 2 and backup the files 3 and 4 into other dir.
2. 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?
Thanks,
Raja.
Last edited by Franklin52; 10-06-2010 at 03:26 AM..
Reason: code tags
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 ----------
Quote:
Originally Posted by Chubler_XL
for files in dir but not in listfile use:
For files in listfile but not in dir use:
Look carefully on my code. Your ll command with -l option already, that's why you get wrong command.
try to use
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).
Hi Folks,
I have one query that there is a folder in which daily several logs files are getting created , I reached to that location through putty but what I observer that 10 files of different date are been created with same name , what I need to see is the latest file ...let say the location is ... (5 Replies)
hi all,
not sure if this has been posted b4 but i try to search but not valid.
this is my question:
when i do a ls -ltr there will be a list generated as follows:
-rw-r--r-- 1 root sys 923260 Jan 10 04:38 FilePolling.41025.083TL021.xml
-rw-r--r-- 1 root sys 1761337 Jan 10 04:40... (12 Replies)
Hi,
I grep for a pattern in a list of files.
"grep -i -l $pattern *.datx*"
it may give me n number of files.
say for eg, it gives me 2 files.
lock_eicu_20071228_00000000.dat_20071228_05343100
lock_eicu_20080501_00000000.dat_20080501_05343900
out of these 2 files I need to get the... (7 Replies)
Hi everyone,
Please help:)
I have a list of 1000 different files which comes daily to the directory.Some of
the files are not coming to the directory now.
I need to write a shell script to find the latest date and time of the files they
came to the directory. The files should be unique.... (1 Reply)
Guys,
I've got a quick logic question. I'm pretty savvy when it comes to shell scripting, however, I'm at a loss when it comes to writing a simple shell script to backup only certain files out of the month. I have a directory, for example, /data/backups/websites/domain. In each "domain"... (5 Replies)
I want to loop through files in a directory but omit the file with the latest date in my list of files. How would I accomplish this?
Thanks (2 Replies)
Hi All,
I have a situation where I need to copy the files having the latest date.
For example I have a file by name bas100e1_jun05. I need to copy it to bas100e1. But when a file by name bas100e1_jul05 is put in the same directory the script should copy the file having the latest month which... (34 Replies)