Search code examples
unixwildcardcp

Can we able to take a backup of the file using wildcard


we have some files like dev_app_s01.properties dev2_app2_s01.properties qa_app_s02.properties

Planning to backup one of any file using wildcard suing shell script like cp *.properties *.properties_BAK_DATE

The output should be like below: dev_app_s01.properties to dev_app_s01.properties_BAK_DDMMYY


Solution

  • One method could be sticking a for loop around one of these many solutions:

    https://unix.stackexchange.com/questions/96380/how-to-append-date-to-backup-file

    The gist would be:

    for i in dev*_app*.properties
    do
       cp {i} {i}-`date`.properties
    done