General discussion

Locked

Sco Open Server file rename

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.

This conversation is currently closed to new comments.

5 total posts (Page 1 of 1)  
| Thread display: Collapse - | Expand +

All Comments

Collapse -

Sco Open Server file rename

by jeremyc In reply to Sco Open Server file rena ...

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"

Collapse -

Sco Open Server file rename

by tstad In reply to Sco Open Server file rena ...

The question was auto-closed by TechRepublic

Collapse -

Sco Open Server file rename

by wcf In reply to Sco Open Server file rena ...

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

Collapse -

Sco Open Server file rename

by tstad In reply to Sco Open Server file rena ...

The question was auto-closed by TechRepublic

Collapse -

Sco Open Server file rename

by tstad In reply to Sco Open Server file rena ...

This question was auto closed due to inactivity

Back to Linux Forum
5 total posts (Page 1 of 1)  

Related Discussions

Related Forums