<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: script to sequence log files in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/script-to-sequence-log-files/m-p/2995610#M913675</link>
    <description>A useful hint is the typeset command in ksh.  Use 'typeset -Z3 name' to make sure the variable 'name' is always printed with 3 digits, leading zeros.&lt;BR /&gt;&lt;BR /&gt;ie: &lt;BR /&gt;typeset -Z3 name&lt;BR /&gt;a=1&lt;BR /&gt;echo $a&lt;BR /&gt;001&lt;BR /&gt;&lt;BR /&gt;This will simplify the filenaming side of things.</description>
    <pubDate>Fri, 13 Jun 2003 07:36:36 GMT</pubDate>
    <dc:creator>Martin Robinson</dc:creator>
    <dc:date>2003-06-13T07:36:36Z</dc:date>
    <item>
      <title>script to sequence log files</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-to-sequence-log-files/m-p/2995606#M913671</link>
      <description>Hi,&lt;BR /&gt;&lt;BR /&gt;I'm trying to simplify a script I have for sequencing files, maybe someone has one already or advice on the best way to go about it?&lt;BR /&gt;&lt;BR /&gt;The script applies sequence numbers to log files each day from 001-&amp;gt;100.&lt;BR /&gt;&lt;BR /&gt;File names are of the format &lt;DATE_TIME&gt;.log, so I want to change them to 001&lt;DATE_TIME&gt;.log up to 100&lt;DATE_TIME&gt;.log, and then start again at 001 by running the script each day.&lt;BR /&gt;&lt;BR /&gt;Any help much appreciated,&lt;BR /&gt;&lt;BR /&gt;Vin.&lt;/DATE_TIME&gt;&lt;/DATE_TIME&gt;&lt;/DATE_TIME&gt;</description>
      <pubDate>Thu, 12 Jun 2003 09:37:43 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-to-sequence-log-files/m-p/2995606#M913671</guid>
      <dc:creator>Vin_5</dc:creator>
      <dc:date>2003-06-12T09:37:43Z</dc:date>
    </item>
    <item>
      <title>Re: script to sequence log files</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-to-sequence-log-files/m-p/2995607#M913672</link>
      <description>&lt;BR /&gt;Try something like this (no hpux on hands)&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;COUNT=1&lt;BR /&gt;&lt;BR /&gt;while $COUNT &amp;lt; 101&lt;BR /&gt;do&lt;BR /&gt;DATE=$( date +%a%I )&lt;BR /&gt;touch /dir/$COUNT$DATE.log&lt;BR /&gt;let COUNT=COUNT+1&lt;BR /&gt;done&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;HTH,&lt;BR /&gt;  Massimo&lt;BR /&gt;</description>
      <pubDate>Thu, 12 Jun 2003 10:02:12 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-to-sequence-log-files/m-p/2995607#M913672</guid>
      <dc:creator>Massimo Bianchi</dc:creator>
      <dc:date>2003-06-12T10:02:12Z</dc:date>
    </item>
    <item>
      <title>Re: script to sequence log files</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-to-sequence-log-files/m-p/2995608#M913673</link>
      <description>Hi:&lt;BR /&gt;&lt;BR /&gt;Assuming that your files were named like '20030612_hhmmss' something like this would do:&lt;BR /&gt;&lt;BR /&gt;#!/usr/bin/sh&lt;BR /&gt;typeset -i N&lt;BR /&gt;typeset    D=`date +%Y%m%d`&lt;BR /&gt;cd /tmp&lt;BR /&gt;for F in `ls f${D}*.log`&lt;BR /&gt;do&lt;BR /&gt;  (( N=N+1 ))&lt;BR /&gt;  mv ${F} ${N}${F}&lt;BR /&gt;done&lt;BR /&gt;exit 0&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...</description>
      <pubDate>Thu, 12 Jun 2003 10:08:29 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-to-sequence-log-files/m-p/2995608#M913673</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2003-06-12T10:08:29Z</dc:date>
    </item>
    <item>
      <title>Re: script to sequence log files</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-to-sequence-log-files/m-p/2995609#M913674</link>
      <description>Hi,&lt;BR /&gt;&lt;BR /&gt;first of all I would create 100 empty files (001.log to 100.log). then it would be easy to run the script every day :&lt;BR /&gt;&lt;BR /&gt;#!/usr/bin/sh&lt;BR /&gt;I=1&lt;BR /&gt;while [ $I -le 100 ]&lt;BR /&gt;do&lt;BR /&gt;  touch $(printf "%3.3d.log" $I)&lt;BR /&gt;  I=$((I+1))&lt;BR /&gt;  sleep 1&lt;BR /&gt;done&lt;BR /&gt;&lt;BR /&gt;without sleep, it seems that files could have creation time in the wrong order. It's run only once, so ...&lt;BR /&gt;&lt;BR /&gt;Then, you can run this script every day. Argument should be the new log file, or you can directly get it from the script using a ls pattern or a date :&lt;BR /&gt;&lt;BR /&gt;#!/usr/bin/sh&lt;BR /&gt;TARGET=$(ls -rt [01][0-9]*.log | line)&lt;BR /&gt;mv $1 $(echo $TARGET | cut -c1-3)_$1&lt;BR /&gt;rm $TARGET&lt;BR /&gt;&lt;BR /&gt;Regards.</description>
      <pubDate>Thu, 12 Jun 2003 10:24:52 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-to-sequence-log-files/m-p/2995609#M913674</guid>
      <dc:creator>Jean-Louis Phelix</dc:creator>
      <dc:date>2003-06-12T10:24:52Z</dc:date>
    </item>
    <item>
      <title>Re: script to sequence log files</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-to-sequence-log-files/m-p/2995610#M913675</link>
      <description>A useful hint is the typeset command in ksh.  Use 'typeset -Z3 name' to make sure the variable 'name' is always printed with 3 digits, leading zeros.&lt;BR /&gt;&lt;BR /&gt;ie: &lt;BR /&gt;typeset -Z3 name&lt;BR /&gt;a=1&lt;BR /&gt;echo $a&lt;BR /&gt;001&lt;BR /&gt;&lt;BR /&gt;This will simplify the filenaming side of things.</description>
      <pubDate>Fri, 13 Jun 2003 07:36:36 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-to-sequence-log-files/m-p/2995610#M913675</guid>
      <dc:creator>Martin Robinson</dc:creator>
      <dc:date>2003-06-13T07:36:36Z</dc:date>
    </item>
  </channel>
</rss>

