06-05-2009
sort for timestamp information-YYYY-MM-DD HH:MM:SS
Dear all,
Please advice how do I sort a file based on timestamp information. I want to sort the second column in asc/desc order which has timestamp information in format YYYY-MM-DD HH:MM:SS
Example
File - Input.txt contains
cat ss.txt
100|2009-03-30 11:38:43
141|2009-06-01 12:12:01
200|2009-06-01 12:10:01
200|2009-06-01 12:11:01
When i run command below, I get result as
sort -t'|' -k2,n Input.txt
100|2009-03-30 11:38:43
141|2009-06-01 12:12:01
200|2009-06-01 12:10:01
200|2009-06-01 12:11:01
But the correct expected output [ which means HH:MM:SS part should also be sorted] is
100|2009-03-30 11:38:43
141|2009-06-01 12:10:01
200|2009-06-01 12:11:01
200|2009-06-01 12:12:01
How do I get this expected output, please advice
Regards,
SUresh
10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
I want to change a date from format dd-mmm-yyyy to mm/dd/yyyy. Is there a way to do this with sed or do you have to write a case statement to convert JAN to 01? Thanks (9 Replies)
Discussion started by: stringzz
9 Replies
2. Shell Programming and Scripting
How to convert the date field from dd/mm/yyyy to yyyy/mm/dd in unix
my script will generate text file which have two fields
one is date and another is name of the server for example this is sample date which I have to sort based on older to newer date the problem is when I found out sort will... (4 Replies)
Discussion started by: pareshan
4 Replies
3. Shell Programming and Scripting
Hi all
I have some pipe-separated data in the form:
5/12/2008 00:00:00|31/1/2009 00:00:00|SOMESTUFF|OTHERSTUFF
12/31/2008 00:00:00|15/1/2009 00:00:00|MORESTUFF|REMAININGSTUFF
1/1/1023 00:00:00|16/5/2047 00:00:00|THEREST|YETMORE
I need to zero-pad the single-digit days and months, using... (3 Replies)
Discussion started by: jgrogan
3 Replies
4. UNIX for Dummies Questions & Answers
Hello Group,
I would like to sort the below file by date (first year then month and day) and I used the following command but it does not work
sort -n -t"/" -k3 -k1 -k2
"sample original file"
12/28/2009,1.0353
12/31/2009,1.0357
12/30/2009,1.0364
12/29/2009,1.0366
12/24/2009,1.0386... (6 Replies)
Discussion started by: csierra
6 Replies
5. Shell Programming and Scripting
Hello,
I am writing a script that parses different logs and produces one. In the source files, the date is in DD MM YYYY HH24:MI:SS format. In the output, it should be in DD MON YYY HH24:MI:SS (ie 25 Jan 2010 16:10:10)
To extract the dates, I am using shell substrings, i.e.:
read line
... (4 Replies)
Discussion started by: Adamm
4 Replies
6. Programming
Hi All,
I am new to Perl. I have a scenario to code. In a folder I have number of files and they will start with P01 or P02 or P03 and so on..I have to sort them on name first and then on time stamp.
Ex.
File name timestamp
P01_file1.txt 1PM
P02_file1.txt 1AM
P01_file2.txt 2PM... (12 Replies)
Discussion started by: unankix
12 Replies
7. Shell Programming and Scripting
I have the following csv data that I would like to sort on the 4th field by date
from oldest to newest.
data:
,,,02/06/2012,Carry H,Add,Add,Sys_RTH,111.222.333.777
4/7/12,,,03/03/2013,Parry H,Add,Add,Sys_RTH,111.222.333.776
,,,12/06/2012,Harry H,Add,Add,Sys_RTH,111.222.333.778... (3 Replies)
Discussion started by: wbrunc
3 Replies
8. Shell Programming and Scripting
Hi,
In Solaris 5.10, can I run a command or a small script that will output
CPU% user, system, wait and idle (The output from iostat or vmstat)
along with a date/timestamp. The date/timestamp can be in any
format that is easy to understand.
I intend to use crontab to call the script once... (2 Replies)
Discussion started by: QZ1
2 Replies
9. Shell Programming and Scripting
Hello All,
I have a date in DD/MM/YYYY format. I am trying to convert this into unix timestamp. I have tried following:
date -d $mydate +%s
where mydate = 23/12/2016 00:00:00
I am getting following error:
date: extra operand `+%s'
Try `date --help' for more information.
... (1 Reply)
Discussion started by: angshuman
1 Replies
10. Shell Programming and Scripting
Used below command to get list of files sorted by timestamp
find -L . -type f -name '*dat*' | xargs ls -ltrg
I want to get only the filenames so I tried adding basename but it doenst work , can some one advise on how to get only file name (1 Reply)
Discussion started by: lalitpct
1 Replies
LEARN ABOUT DEBIAN
eurephiadm-lastlog
eurephiadm lastlog(7) eurephiadm lastlog(7)
NAME
eurephiadm-lastlog - View the eurephia lastlog
SYNOPSIS
eurephiadm lastlog [-v|--verbose] [-S|--sortkeys <sort keys>] [<FILTER arguments>]
DESCRIPTION
This command will query the lastlog records, which contains information about all logins done with the eurephia-auth plug-in.
OPTIONS
-S | --sortkeys <sort key>[,<sort key>[,<sort key>]...]
Sorting order of the report. More sort keys can be given, separated by comma. The available sort keys are:
uid : User ID
certid : Certificate ID
ip : IP address where the client connects from
vpnip : Assigned IP address on the VPN client
status : eurephia connection status
login : When the client logged in
logout : When the client logged out
username : eurephia username
macaddr : MAC address of the TUN/TAP interface on the VPN client
uicid : User ID/Certificate ID link ID. Related to the IDs provided by eurephiadm usercerts
-v | --verbose
View detailed lastlog
FILTERS
The filters can help reducing the amount of data being reported. Multiple filters may be added, but they will only work as additional
"AND" arguments in the query.
-c | --certid <Certificate ID>
Certificate ID
-i | --uid <User ID>
Numeric user ID
-u | --username <User name>
User name
-I | --ip-addr <IP address>
IP address of remote host
-s | --login <YYYY-MM-DD>
Login time
-e | --logout <YYYY-MM-DD>
Logout time
-m | --mac-addr <TUN/TAP MAC address>
MAC address of remote VPN interface of the client
-a | --uicid <Access ID>
User ID/Certificate ID link ID. Related to the IDs provided by eurephiadm usercerts
SEE ALSO
eurephiadm(7), eurephiadm-certs(7), eurephiadm-users(7), eurephiadm-usercerts(7)
AUTHOR
Copyright (C) 2008-2010 David Sommerseth <dazo@users.sourceforge.net>
David Sommerseth July 2010 eurephiadm lastlog(7)