Concatenate date to file name

Hi,

I have written a script to rename a file, but I can not add the current date (in YYYYMMDD-HHMM format)

can you please look at this cript, and help?
thanks,

#!/usr/local/bin/tcsh -f

set server = "$1"
set user = "$2"

if (-f $server) then
\mv $server $server.Saar.[HERE_I_WANT_DATE]
endif

Not completely sure if this will work with tcsh, but you can give it a shot. My OS is Dynix/ptx.

D=`date +%Y%m%d-%H%M`
echo $D

Sorry...I didn't mention that this would just get you the date, and that you would have to incorporate it into your command line.

Try ...

\mv $server $server.Saar.`date '+%Y%m%d-%H%M'`

:stuck_out_tongue: , Thanks.

theKid: your answer didn't work, but thanks for trying.

Cameron, yours did, thanks.
:slight_smile:

sierra_aar,
thekids was logically correct but in the syntax used forgot the single quote's(') around the date para's.
An oversight that anyone could make.
Otherwise, glad I could help out.