Friday 22 February 2013

Rename file in UNIX before Copy File.

The below function is used to rename the existing file before checking in the directory. 
For the first time it will copy and from second time onwords it will rename with SYSDATE.



function COPYFILE
{
    [[ -f "$2/$1" ]] && mv "$2/$1" "$2/$1".$(date '+%d%m%Y')
    cp "$1" "$2"



COPYFILE XYZ.rdf  $AR_TOP/reports/US

No comments:

Post a Comment