<?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: changing date in filename with shell script in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/changing-date-in-filename-with-shell-script/m-p/3260725#M888342</link>
    <description>File=PP7K_20040426120002.drf&lt;BR /&gt;&lt;BR /&gt;Cron entry that will run at mid-night and mid-day&lt;BR /&gt;&lt;BR /&gt;mv ${File} PP7K_`date +%Y%m%d%H%M%S`.drf&lt;BR /&gt;&lt;BR /&gt;Anil</description>
    <pubDate>Tue, 27 Apr 2004 13:39:22 GMT</pubDate>
    <dc:creator>RAC_1</dc:creator>
    <dc:date>2004-04-27T13:39:22Z</dc:date>
    <item>
      <title>changing date in filename with shell script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/changing-date-in-filename-with-shell-script/m-p/3260723#M888340</link>
      <description>Hi,&lt;BR /&gt;&lt;BR /&gt;I've been tasked with creating a unix shell script that will update the date in the filename string to the current date &amp;amp; time. i.e. the file is currently named PP7K_20040426120002.drf and I would like to change it twice a day at mid-night and mid-day. Therefore at today midnight the filename would be changed to PP7K_20040427000000.drf and at mid-day today the filename would be changed to PP7K_20040427120000.drf etc, etc.&lt;BR /&gt;&lt;BR /&gt;I'm a beginner at shell scripting and would be greatly appreciate any help that can be provided.&lt;BR /&gt;&lt;BR /&gt;Cheers&lt;BR /&gt;&lt;BR /&gt;AK&lt;BR /&gt;</description>
      <pubDate>Tue, 27 Apr 2004 13:28:10 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/changing-date-in-filename-with-shell-script/m-p/3260723#M888340</guid>
      <dc:creator>Andy Koumi_1</dc:creator>
      <dc:date>2004-04-27T13:28:10Z</dc:date>
    </item>
    <item>
      <title>Re: changing date in filename with shell script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/changing-date-in-filename-with-shell-script/m-p/3260724#M888341</link>
      <description>#! /bin/sh&lt;BR /&gt;&lt;BR /&gt;#assume only 1 in the directory&lt;BR /&gt;var=`ls -1 PK7K_*.drf`  &lt;BR /&gt;&lt;BR /&gt;mv $var PP7K_`date+%Y%m%d%H%M%S`.drf&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;this is about as simple as it gets.&lt;BR /&gt;if you just need to create a new file, and leave the old one, it is much simpler&lt;BR /&gt;&lt;BR /&gt;#! /bin/sh&lt;BR /&gt;touch PP7K_`date+%Y%m%d%H%M%S`.drf&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;this is much simpler.&lt;BR /&gt;&lt;BR /&gt;Regards&lt;BR /&gt;Scott Palmer&lt;BR /&gt;</description>
      <pubDate>Tue, 27 Apr 2004 13:33:43 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/changing-date-in-filename-with-shell-script/m-p/3260724#M888341</guid>
      <dc:creator>Scott Palmer_1</dc:creator>
      <dc:date>2004-04-27T13:33:43Z</dc:date>
    </item>
    <item>
      <title>Re: changing date in filename with shell script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/changing-date-in-filename-with-shell-script/m-p/3260725#M888342</link>
      <description>File=PP7K_20040426120002.drf&lt;BR /&gt;&lt;BR /&gt;Cron entry that will run at mid-night and mid-day&lt;BR /&gt;&lt;BR /&gt;mv ${File} PP7K_`date +%Y%m%d%H%M%S`.drf&lt;BR /&gt;&lt;BR /&gt;Anil</description>
      <pubDate>Tue, 27 Apr 2004 13:39:22 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/changing-date-in-filename-with-shell-script/m-p/3260725#M888342</guid>
      <dc:creator>RAC_1</dc:creator>
      <dc:date>2004-04-27T13:39:22Z</dc:date>
    </item>
    <item>
      <title>Re: changing date in filename with shell script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/changing-date-in-filename-with-shell-script/m-p/3260726#M888343</link>
      <description>I have a process I use to mv log files and date then in a similar fashion.. &lt;BR /&gt;&lt;BR /&gt;for example: &lt;BR /&gt;&lt;BR /&gt;each day an file "export.log" is built in my log directory. I want to retain a weeks worth of export.log as export.log is overwritten nightly, I only want to capture it after the process has ran each day&lt;BR /&gt;in crontab my job looks like this&lt;BR /&gt;&lt;BR /&gt;30 23 * * * /scripts/logrename &lt;BR /&gt;&lt;BR /&gt;the script is simple, &lt;BR /&gt;#LOGRENAME script&lt;BR /&gt;mv /logfiles/export.log /logfiles/backup/export`date +%y%m%d_%H%M%S`.log &lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;If I wanted two copys I add a second entry in the crontab; &lt;BR /&gt;30 12 * * * /scripts/logrename &lt;BR /&gt;30 23 * * * /scripts/logrename &lt;BR /&gt;&lt;BR /&gt;this holds as log as the name of the original file is a constant, if the file name is a variable, then you'd have to parse your original file name with the ls command, and search for the intended string, and use it as a variable, in parameter $1 of the mv command.. &lt;BR /&gt;</description>
      <pubDate>Wed, 28 Apr 2004 08:08:21 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/changing-date-in-filename-with-shell-script/m-p/3260726#M888343</guid>
      <dc:creator>rmueller58</dc:creator>
      <dc:date>2004-04-28T08:08:21Z</dc:date>
    </item>
  </channel>
</rss>

