sorting of files on the basis of timestamp


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting sorting of files on the basis of timestamp
# 1  
Old 02-23-2009
sorting of files on the basis of timestamp

Hi,

With the help of below script im able to get the count of all the .xml files but that count is not specific to a day ie its the total count of all .xml files what i want is specific to 1 day and that of every half an hr ie from 23 feb 2009 7 am till 23rd feb 2009 2300 am and from 07:00 to 7:30 then 5 mins sleep time and then again 07:35 to 08:05 and so on till 2300.

the filename is of the format:
MNP_PORT_IN_P200902201800429992_20090223111443.xml

where 5th field is timestamp of foemat YYYYMMDDHHMMSS

#!/bin/sh

smsto1=0132777094
timeout=300

while :
do

TIME=`date '+%H%M'`
START=0700
END=2300

if [ $TIME -ge $START ] && [ $TIME -le $END ]
then rcvd_file_cnt=`ls -l /SYSTEM/custom/data/MNP/xmlerror | sed -n '/\([A-Z]\{3\}\)_\([A-Z]\{4\}\)_\([A-Z]\{2\}\)_P\([0-9]\{18\}\)_\([0-9]\{14\}\).xml/p' |wc -l`

echo "Count is" $rcvd_file_cnt


[ $rcvd_file_cnt -eq 0 ] && { sendsms_all.exe $smsto1 "(ALERT) Greater Than 25 files received today."; }
[ $rcvd_file_cnt -gt 0 -a $rcvd_file_cnt -le 2 ] && { sendsms_all.exe $smsto1 "(ALERT) Greater Than 25 files received."; }
fi

sleep $timeout
done

please help in this regard.
# 2  
Old 02-23-2009
Similar question of this:

https://www.unix.com/shell-programmin...#post302290281

It's not allowed to double post questions, please read the rules.

Thread closed.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

LDIF Data sorting by timestamp

I am a newbie and need awk or sed script to run against LDIF format data and sort by create time stamp (2 Replies)
Discussion started by: atlowi
2 Replies

2. Shell Programming and Scripting

Sorting on date basis

I have file data.txt having below data cat data.txt 01-MAY-13 2.38.11.00.100089 IN 4512 0000741881 01-MAY-13 2.38.11.00.100089 IN 4512 0000741881 01-JUN-13 2.38.11.00.100089 FC 1514 0000764631 01-NOV-13 2.38.11.00.100089 FC 1514 0000856571 01-NOV-13 2.38.11.00.100089 IN 300.32... (1 Reply)
Discussion started by: ranabhavish
1 Replies

3. Shell Programming and Scripting

Plz Help in sorting the data on date basis

I have file a.txt having below data cat a.txt 01-MAY-13 2.38.11.00.100089 IN 4512 0000741881 01-JUN-13 2.38.11.00.100089 IN 1514 0000764631 01-NOV-13 2.38.11.00.100089 IN 1514 0000856571 01-NOV-13 2.38.15.00.100015 IN 300.32 0000856531 01-JUN-13 2.38.19.00.100000 IN 2698 0000764493... (5 Replies)
Discussion started by: ranabhavish
5 Replies

4. UNIX for Dummies Questions & Answers

Plz Help in sorting the data on date basis

I have file having below data 01-MAY-13 2.38.11.00.100089 IN 4512 0000741881 01-JUN-13 2.38.11.00.100089 IN 1514 0000764631 01-NOV-13 2.38.11.00.100089 IN 1514 0000856571 01-NOV-13 2.38.15.00.100015 IN 300.32 0000856531 01-JUN-13 2.38.19.00.100000 IN 2698 0000764493 01-JUL-13... (2 Replies)
Discussion started by: ranabhavish
2 Replies

5. Shell Programming and Scripting

Separate a file on the basis of timestamp

hi, I have a log file which contains data for last 7 seven days. I want to copy all the data for 6 days in one file and keep only the data for today in that log file and mail that log file containing today's data. Log file is in this format Time: 120529 10:51:08 User@Host: local @ ... (4 Replies)
Discussion started by: arijitsaha
4 Replies

6. UNIX for Dummies Questions & Answers

Sorting files based on timestamp and picking the latest file

Hi Friends, Newbie to shell scripting Currently i have used the below to sort data based on filenames and datestamp $ printf '%s\n' *.dat* | sort -t. -k3,4 filename_1.dat.20120430.Z filename_2.dat.20120430.Z filename_3.dat.20120430.Z filename_1.dat.20120501.Z filename_2.dat.20120501.Z... (12 Replies)
Discussion started by: robertbrown624
12 Replies

7. Shell Programming and Scripting

Urgent ...pls Sorting files based on timestamp and picking the latest file

Hi Friends, Newbie to shell scripting. Currently i have used the below to sort data based on filenames and datestamp $ printf '%s\n' *.dat* | sort -t. -k3,4 filename_1.dat.20120430.Z filename_2.dat.20120430.Z filename_3.dat.20120430.Z filename_1.dat.20120501.Z filename_2.dat.20120501.Z... (1 Reply)
Discussion started by: robertbrown624
1 Replies

8. Shell Programming and Scripting

Identifying files with a timestamp greater than a given timestamp

I need to be able to identify files with file timestamps greater than a given timestamp. I am using the following solution, although it appears to compare files at the "seconds" granularity and I need it at the milliseconds. When I tested my solution, it missed files that had timestamps... (3 Replies)
Discussion started by: nkm0brm
3 Replies

9. Shell Programming and Scripting

Group on the basis of common text in the square bracket and sorting

File A 99 >ac >ss >juk 70 >acb >defa 90 >ca 100 >aa >abc >bca 85 >cde 81 >ghi >ghij 87 >def >fgh <ijk 89 >fck >ghij >kill >aa The given output shud be 100 >aa >abc >bca 87 >def >fgh <ijk 89 >fck >ghij >kill >aa (2 Replies)
Discussion started by: cdfd123
2 Replies

10. Shell Programming and Scripting

Moving files on first in first out basis

suppose in a directory there are over 20 files. I need to move the first 10 files(first in first out basis, which ever files comes first) into a separate directory. i have an idea but not sure how far this is correct, can anyone guide me on this? find /opt/logs -name "cor*" -mtime 2... (6 Replies)
Discussion started by: venkatesht
6 Replies
Login or Register to Ask a Question