Note that there are some explanatory texts on larger screens.

plurals
  1. PObash sort - how do I sort using timestamp
    primarykey
    data
    text
    <p>I need to sort a file using shell sort in linux. The sort needs to be based on timestamp values contained within each of file's rows. The timestamps are of irregular format and don’t specify the leading zeros to months, days, etc, so the sorts I am performing are not correct (i.e. their format is “M/D/YYYY H:MI:S AM”; so so “10/12/2012 12:16:18 PM” comes before “7/24/2012 12:16:18 PM”, which comes before “7/24/2012 12:17:18 AM”). </p> <p>Is it possible to sort based on timestamps?</p> <p>I am using the following command to sort my file:</p> <pre><code>sort -t= -k3 file.txt -o file.txt.sorted </code></pre> <p>(use equal sign as a separator => <code>-t=</code>; use 3rd column as a sort column => <code>-k3</code>)</p> <p>A sample file is as follows:</p> <pre><code>&lt;r id="abcd" t="10/12/2012 12:16:17 AM"&gt;&lt;d&gt;&lt;nv n="name" v="868" /&gt;&lt;nv n="name0" v="73" /&gt;&lt;nv n="name1" v="13815004" /&gt;&lt;/d&gt;&lt;/r&gt; &lt;r id="defg" t="7/24/2012 12:16:17 PM"&gt;&lt;d&gt;&lt;nv n="name" v="0" /&gt;&lt;nv n="name0" v="0" /&gt;&lt;nv n="name1" v="0" /&gt;&lt;/d&gt;&lt;/r&gt; &lt;r id="abcd" t="7/24/2012 12:16:17 PM"&gt;&lt;d&gt;&lt;nv n="name" v="0" /&gt;&lt;nv n="name0" v="0" /&gt;&lt;nv n="name1" v="0" /&gt;&lt;/d&gt;&lt;/r&gt; &lt;r id="zxy" t="7/24/2012 12:16:17 PM"&gt;&lt;d&gt;&lt;nv n="name" v="0" /&gt;&lt;nv n="name0" v="0" /&gt;&lt;nv n="name1" v="59542676" /&gt;&lt;/d&gt;&lt;/r&gt; &lt;r id="fghj" t="7/24/2012 12:16:17 PM"&gt;&lt;d&gt;&lt;nv n="name" v="38" /&gt;&lt;nv n="name0" v="0" /&gt;&lt;nv n="name1" v="3004537" /&gt;&lt;/d&gt;&lt;/r&gt; &lt;r id="defg" t="7/24/2012 12:16:18 AM"&gt;&lt;d&gt;&lt;nv n="name" v="177" /&gt;&lt;nv n="name0" v="0" /&gt;&lt;nv n="name1" v="5888870" /&gt;&lt;/d&gt;&lt;/r&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload