Discussion Locked

Sco Open Server file rename

0 helpful
5 replies
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.
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.

5 replies

by jeremyc

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"

by wcf

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

This discussion is closed to new replies.