Listing files from October 4th is not accurate


 
Thread Tools Search this Thread
Top Forums UNIX for Beginners Questions & Answers Listing files from October 4th is not accurate
# 1  
Old 10-08-2018
Listing files from October 4th is not accurate

Good evening:
Need your help please

Before deleting older logs from octobre 4th i need to identify which files i have to remove, for instance today is octobre 8ht, i need to remove files from October 4th

Because there are many files i can not list because error args too long, so

Code:
/produccion/explotacion/xpfactur/facturacion/log/CRMLogs/nociclo # ls|wc -l
500318

Thos is the command:

Code:
find ./ -mtime +4 -name "Impres*.log" -type f -exec ls -lrt {} \;|more

output:

Code:
rw-r--r--   1 xpfactur explotacion  945067 Sep 25 01:00 ./CRMLogs_11583846.log
-rw-r--r--   1 xpfactur explotacion  927900 Sep 25 01:00 ./CRMLogs_11605696.log
-rw-r--r--   1 xpfactur explotacion  922556 Sep 25 01:00 ./CRMLogs_11591810.log
-rw-r--r--   1 xpfactur explotacion  945192 Sep 25 01:00 ./CRMLogs_11631276.log
-rw-r--r--   1 xpfactur explotacion  922258 Sep 25 01:00 ./CRMLogs_11559556.log

above just list files from september 25th, but files from octuber 4rth really exists when i use this command:

Code:
SCEL /produccion/explotacion/xpfactur/facturacion/log/CRMLogs/nociclo # find ./ -name "CRMLogs*" -type f -mtime -7 -exec ls -l {} \;|more
-rw-r--r--   1 xpfactur explotacion  122108 Oct  4 09:45 ./CRMLogs_11824221.log.gz
-rw-r--r--   1 xpfactur explotacion  122149 Oct  4 10:01 ./CRMLogs_11824388.log.gz
-rw-r--r--   1 xpfactur explotacion  122068 Oct  3 11:51 ./CRMLogs_11814440.log.gz
-rw-r--r--   1 xpfactur explotacion  121271 Oct  3 15:25 ./CRMLogs_11817732.log.gz
-rw-r--r--   1 xpfactur explotacion  121857 Oct  3 16:53 ./CRMLogs_11819599.log.gz
-rw-r--r--   1 xpfactur explotacion  122364 Oct  4 11:19 ./CRMLogs_11825342.log.gz
-rw-r--r--   1 xpfactur explotacion  122101 Oct  4 12:07 ./CRMLogs_11826156.log.gz
-rw-r--r--   1 xpfactur explotacion  123191 Oct  4 12:09 ./CRMLogs_11826190.log.gz
-rw-r--r--   1 xpfactur explotacion  123294 Oct  4 12:14 ./CRMLogs_11826738.log.gz
-rw-r--r--   1 xpfactur explotacion  122536 Oct  4 12:18 ./CRMLogs_11827227.log.gz
-rw-r--r--   1 xpfactur explotacion  121686 Oct  4 12:24 ./CRMLogs_11827749.log.gz
-rw-r--r--   1 xpfactur explotacion  122314 Oct  4 12:28 ./CRMLogs_11828380.log.gz
-rw-r--r--   1 xpfactur explotacion  122155 Oct  4 14:29 ./CRMLogs_11830152.log.gz
-rw-r--r--   1 xpfactur explotacion  121209 Oct  4 17:20 ./CRMLogs_11832826.log.gz
-rw-r--r--   1 xpfactur explotacion  122128 Oct  4 18:21 ./CRMLogs_11834403.log.gz
-rw-r--r--   1 xpfactur explotacion  122126 Oct  4 18:21 ./CRMLogs_11834425.log.gz
-rw-r--r--   1 xpfactur explotacion  122357 Oct  4 18:38 ./CRMLogs_11834942.log.gz
-rw-r--r--   1 xpfactur explotacion  122341 Oct  4 18:59 ./CRMLogs_11835504.log.gz
-rw-r--r--   1 xpfactur explotacion  121782 Oct  8 00:28 ./CRMLogs_12031105.log.gz
-rw-r--r--   1 xpfactur explotacion  121780 Oct  8 00:29 ./CRMLogs_12031056.log.gz
-rw-r--r--   1 xpfactur explotacion  121213 Oct  4 23:32 ./CRMLogs_11837553.log.gz
-rw-r--r--   1 xpfactur explotacion  121458 Oct  4 23:36 ./CRMLogs_11838724.log.gz
-rw-r--r--   1 xpfactur explotacion  121468 Oct  4 23:42 ./CRMLogs_11838186.log.gz


how to get around this to list excactly logs from October 4th ?

the opartating system is:

Code:
SunOS serber100c 5.10 Generic_144488-01 sun4u sparc SUNW,SPARC-Enterprise


I appreciate your help in advanced
# 2  
Old 10-09-2018
Moderator's Comments:
Mod Comment The thread title of this thread has been changed from "Listing files ftom Octobre 4th is not accurate" to "Listing files from October 4th is not accurate" hoping to make searches for similar threads more likely to find a match.


Assuming that you don't need to descend into a file hierarchy and just want to process files in your current working directory, a couple of obvious choices would be:
Code:
ls -l | grep 'CRMLogs' | grep 'Oct  4'

and:
Code:
ls -l | /usr/xpg4/bin/awk '$6 == "Oct" && $7 == "4" && $9 ~ "CRMLogs"'

If you do need to descend into the file hierarchy rooted in your current working directory, you could also try:
Code:
#!/bin/ksh
ls -lR | /usr/xpg4/bin/awk '
$1 ~ ":$" {
	dir = substr($1, 1, length($1) - 1) "/"
	next
}
$6 == "Oct" && $7 == 4 && $9 ~ /CRMLogs/ {
	print dir $9
}'

This code assumes that none of your filenames contain any whitespace characters.
These 3 Users Gave Thanks to Don Cragun For This Post:
# 3  
Old 10-09-2018
thanks you very much, there is no file hierarchy , there are no subfolders so the 1st choice applies.

Identifying files from october 4th i assume i have to script to delete or compress these files right ?

because the purpose of using the find command gives me the pipeline facility and delete and log the removed files at once

I appreciate your help in advanced
# 4  
Old 10-09-2018
You don't mention your OS, shell, nor find versions. Should you have bash (I think the "%(%s)T" format works in other shells as well), and GNU find, you could try
Code:
BEG=$(printf "%s\n" $(( ( $(printf "%(%s)T") - $(date +"%s" -d"oct 4")) / 60 ))); END=$((BEG-1440)); find . -maxdepth 1 -mmin -$BEG \! -mmin -$END -ls -delete

# 5  
Old 10-10-2018
Thanks again. Regarding the OPerating System is:

Code:
SunOS serber100c 5.10 Generic_144488-01 sun4u sparc SUNW,SPARC-Enterprise

So the above solution works for this environment and operating system?
# 6  
Old 10-10-2018
Hi. No, RudiC's suggestion does not work with Solaris 10.
This User Gave Thanks to Scrutinizer For This Post:
Login or Register to Ask a Question

Previous Thread | Next Thread

8 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Compress and logging files from October 6th in a loop

Good night, i need your help please Because there are about 10000 files from October 6th, i need to to compress but i use this command and it does not do anything, in the prompt has no respones and i have to press CRTL+C to goback to the shell for file in $(ls -l | grep "Impres" | grep "Oct ... (4 Replies)
Discussion started by: alexcol
4 Replies

2. Shell Programming and Scripting

Listing the file name and no of records in each files for the files created on a specific day

Hi, I want to display the file names and the record count for the files in the 2nd column for the files created today. i have written the below command which is listing the file names. but while piping the above command to the wc -l command its not working for me. ls -l... (5 Replies)
Discussion started by: Showdown
5 Replies

3. Shell Programming and Scripting

Output is not Accurate

list db directory |grep alias |awk '{print "connect to ",$4}' In a shell script the below line should display output as below connect to <DATABASENAME> but its throwing error like Syntax Error The source line is 1. The error context is {print connect to,... (8 Replies)
Discussion started by: rocking77
8 Replies

4. SuSE

Listing files

Hi, This may be silly for some of you guys, but please guide me, I have the followin fies in my directory, root@unix:/onlineredo/XTT77 : ls -l total 4129992 -rw------- 1 XTT77 XTT77 10493952 Jul 28 2010 S0106839.LOG -rw------- 1 XTT77 XTT77 10493952 Jul 28 2010 S0106840.LOG... (3 Replies)
Discussion started by: suren1829
3 Replies

5. Shell Programming and Scripting

perl script for listing files and mailing the all files

Hi, I am new to perl: I need to write perl script to list all the files present in directory and mail should be come to my inbox with all the files present in that directory. advanced thanks for valuable inputs. Thanks Prakash GR (1 Reply)
Discussion started by: prakash.gr
1 Replies

6. UNIX for Advanced & Expert Users

listing files excluding files from control file

I have a directory named Project.I have a control file which contains valid list of files.I would like list the files from directory Project which contains files other than listed in the control file. Sample control file: TEST SEND SFFFILE CONTL The directory contains followign... (15 Replies)
Discussion started by: ukatru
15 Replies

7. Linux

Listing of files

How can I list all files in a directory and its subdirectories that have been created or changed since the system was booted. I was trying to acomplish this with "ls" and "find" commands but could not get anything usefull. Maybe some one can provide me a hint. Thank you for your time. (1 Reply)
Discussion started by: Vitalka
1 Replies

8. UNIX for Dummies Questions & Answers

Recursive directory listing without listing files

Does any one know how to get a recursive directory listing in long format (showing owner, group, permission etc) without listing the files contained in the directories. The following command also shows the files but I only want to see the directories. ls -lrtR * (4 Replies)
Discussion started by: psingh
4 Replies
Login or Register to Ask a Question