Shell script to copy files from one location to another location and rename add the current date to every file

前端 未结 6 563
温柔的废话
温柔的废话 2021-01-30 04:46

I have a folder in my server which contains some files. These are automated that means everyday we get new files automatically which will overwrite the old ones. So want to take

6条回答
  •  無奈伤痛
    2021-01-30 05:05

    You could use a script like the below. You would just need to change the date options to match the format you wanted.

    #!/bin/bash
    
    for i in `ls -l /directroy`
    do
    cp $i /newDirectory/$i.`date +%m%d%Y`
    done
    

提交回复
热议问题