<?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: Renaming files within a script in Operating System - Linux</title>
    <link>https://community.hpe.com/t5/operating-system-linux/renaming-files-within-a-script/m-p/4135188#M63498</link>
    <description>Hi (again):&lt;BR /&gt;&lt;BR /&gt;&amp;gt; You need a space between date and +.&lt;BR /&gt;&lt;BR /&gt;Had you copied-and-pasted the command I posted (albeit it as a generic example), you would have "seen" the whitespace.&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...</description>
    <pubDate>Thu, 24 Jan 2008 19:45:48 GMT</pubDate>
    <dc:creator>James R. Ferguson</dc:creator>
    <dc:date>2008-01-24T19:45:48Z</dc:date>
    <item>
      <title>Renaming files within a script</title>
      <link>https://community.hpe.com/t5/operating-system-linux/renaming-files-within-a-script/m-p/4135183#M63493</link>
      <description>Hi there --&lt;BR /&gt;&lt;BR /&gt;I have a script that copies files from the localhost to a remote directory. Currently, the script overwrites the existing files in the remote directory. Here is an excerpt:&lt;BR /&gt; &lt;BR /&gt;cd &lt;REMOTE directory=""&gt;&lt;BR /&gt;rm -rf fstab&lt;BR /&gt;rm -rf exports&lt;BR /&gt;rm -rf hosts.equiv&lt;BR /&gt;rm -rf hosts&lt;BR /&gt;rm -rf passwd&lt;BR /&gt;rm -rf .rhosts&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;I would like to change that so that it renames the files with a date extension, ie: filename_24jan08, instead of overwriting them. The script uses the sh shell, but that can be changed if necessary.  How can this be done?&lt;/REMOTE&gt;</description>
      <pubDate>Thu, 24 Jan 2008 17:52:50 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/renaming-files-within-a-script/m-p/4135183#M63493</guid>
      <dc:creator>Andrew Kaplan</dc:creator>
      <dc:date>2008-01-24T17:52:50Z</dc:date>
    </item>
    <item>
      <title>Re: Renaming files within a script</title>
      <link>https://community.hpe.com/t5/operating-system-linux/renaming-files-within-a-script/m-p/4135184#M63494</link>
      <description>Hi Andrew:&lt;BR /&gt;&lt;BR /&gt;# mv myfile myfile.$(date  +%d%b%Y)&lt;BR /&gt;&lt;BR /&gt;...renames "myfile" to "myfile.24Jan2008" (or whatever is the current date.&lt;BR /&gt;&lt;BR /&gt;If the file already exists on the date given, then it will be overwritten during the rename.&lt;BR /&gt;&lt;BR /&gt;By the way, adding the recursive ('-r') switch to a 'rm' for *files* is meaningless.&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...</description>
      <pubDate>Thu, 24 Jan 2008 18:15:14 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/renaming-files-within-a-script/m-p/4135184#M63494</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2008-01-24T18:15:14Z</dc:date>
    </item>
    <item>
      <title>Re: Renaming files within a script</title>
      <link>https://community.hpe.com/t5/operating-system-linux/renaming-files-within-a-script/m-p/4135185#M63495</link>
      <description>&amp;gt;&amp;gt;&amp;gt; I would like to change that so that it renames the files with a date extension&lt;BR /&gt;&lt;BR /&gt;This could have negative effects, as if you don't control the number of "versions", you will have enless list of files.&lt;BR /&gt;&lt;BR /&gt;To avoid this you can:&lt;BR /&gt;&lt;BR /&gt;Name the file as &lt;FILENAME&gt;-&lt;DAY_OF_WEEK&gt;&lt;BR /&gt;&lt;BR /&gt;That would be:&lt;BR /&gt;&lt;BR /&gt;$FILENAME-$(date +%a)&lt;BR /&gt;&lt;BR /&gt;In this case, the date of the file will be identified by the timestamp of the file.&lt;BR /&gt;&lt;BR /&gt;You can put a "find" in your script:&lt;BR /&gt;&lt;BR /&gt;find /somewhere -mtime +7 -exec rm {} \;&lt;/DAY_OF_WEEK&gt;&lt;/FILENAME&gt;</description>
      <pubDate>Thu, 24 Jan 2008 18:19:39 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/renaming-files-within-a-script/m-p/4135185#M63495</guid>
      <dc:creator>Ivan Ferreira</dc:creator>
      <dc:date>2008-01-24T18:19:39Z</dc:date>
    </item>
    <item>
      <title>Re: Renaming files within a script</title>
      <link>https://community.hpe.com/t5/operating-system-linux/renaming-files-within-a-script/m-p/4135186#M63496</link>
      <description>Hi there --&lt;BR /&gt;&lt;BR /&gt;I went ahead and replaced the rm lines with the mv lines. This is the syntax that I used:&lt;BR /&gt;&lt;BR /&gt;mv fstab fstab_$(date+%d%b%Y)&lt;BR /&gt;mv exports exports_$(date+%d%b%Y)&lt;BR /&gt;mv hosts.equiv hosts.equiv_$(date+%d%b%Y)&lt;BR /&gt;mv hosts hosts_$(date+%d%b%Y)&lt;BR /&gt;mv passwd passwd_$(date+%d%b%Y)&lt;BR /&gt;mv .rhosts .rhosts_$(date+%d%b%Y)&lt;BR /&gt;&lt;BR /&gt;However, when I ran the script, the error messages shown below appeared on-screen:&lt;BR /&gt;&lt;BR /&gt;./backup_script: line 1: date+%d%b%Y: command not found&lt;BR /&gt;./backup_script: line 1: date+%d%b%Y: command not found&lt;BR /&gt;./backup_script: line 1: date+%d%b%Y: command not found&lt;BR /&gt;./backup_script: line 1: date+%d%b%Y: command not found&lt;BR /&gt;./backup_script: line 1: date+%d%b%Y: command not found&lt;BR /&gt;./backup_script: line 1: date+%d%b%Y: command not found&lt;BR /&gt;&lt;BR /&gt;I believe it is a syntax error, but I am not sure what it is. &lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Thu, 24 Jan 2008 18:38:26 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/renaming-files-within-a-script/m-p/4135186#M63496</guid>
      <dc:creator>Andrew Kaplan</dc:creator>
      <dc:date>2008-01-24T18:38:26Z</dc:date>
    </item>
    <item>
      <title>Re: Renaming files within a script</title>
      <link>https://community.hpe.com/t5/operating-system-linux/renaming-files-within-a-script/m-p/4135187#M63497</link>
      <description>You need a space between date and +.</description>
      <pubDate>Thu, 24 Jan 2008 18:45:48 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/renaming-files-within-a-script/m-p/4135187#M63497</guid>
      <dc:creator>Ivan Ferreira</dc:creator>
      <dc:date>2008-01-24T18:45:48Z</dc:date>
    </item>
    <item>
      <title>Re: Renaming files within a script</title>
      <link>https://community.hpe.com/t5/operating-system-linux/renaming-files-within-a-script/m-p/4135188#M63498</link>
      <description>Hi (again):&lt;BR /&gt;&lt;BR /&gt;&amp;gt; You need a space between date and +.&lt;BR /&gt;&lt;BR /&gt;Had you copied-and-pasted the command I posted (albeit it as a generic example), you would have "seen" the whitespace.&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...</description>
      <pubDate>Thu, 24 Jan 2008 19:45:48 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/renaming-files-within-a-script/m-p/4135188#M63498</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2008-01-24T19:45:48Z</dc:date>
    </item>
  </channel>
</rss>

