General discussion

  • Creator
    Topic
  • #2082330

    Sco Open Server file rename

    Locked

    by tstad ·

    In previos versions of Sco unix you could rename a file to include today’s date as part of the file name. The command used to be: cp filename date ‘+%m%dname’ and the result would be 0309name. Does anyone know how this command has changed, or howI can “datestamp” a file as part of the file name. I would greatly appreciate any suggestions.

All Comments

  • Author
    Replies
    • #3898359

      Sco Open Server file rename

      by jeremyc ·

      In reply to Sco Open Server file rename

      Try this (I dont’ have a SCO machine to test on, but it should work):

      cp filename filename`date |sed -e “s/ /_/g”`

      Pay attention to the syntax above – the “single quotes” are backticks.

      This will get you this:
      “filename” gets copied to “filenameThu_Mar__9_18:51:04_MST_2000”

    • #3898224

      Sco Open Server file rename

      by wcf ·

      In reply to Sco Open Server file rename

      You are slightly ticked-off for SCO OS5.
      The following suntax works.
      cp filename `date +%m%d`filename
      where ` is a backtic
      But note that this actually creates a COPY of the file and if what you really want is to RENAME the file as you state, use

      mv filename `date +%m%d`filename
      The main thing here is that you enclose the COMMAND in backticks so that the shell executes it and replaces the COMMAND with its output

    • #3739697

      Sco Open Server file rename

      by tstad ·

      In reply to Sco Open Server file rename

      This question was auto closed due to inactivity

Viewing 2 reply threads