keywords : files, shell , backup extension
1 Add a extension (for example .old ) to selected files
=========================================
======= content of file ./backup ======
#!/bin/bash
for FILE in *.$1 ;do cp $FILE $FILE.old; done
exit 0
--------- end of file ---------------------
usage
./backup html
------------------
result : all .html files are now .html.old
=================
2 . Remove the extension to selected files
======== content of file ./unbackup =====
#!/bin/bash
for FILE in *.old ; do cp $FILE `basename $FILE .old`; done
exit 0
------------------------------
usage
./unbackup
all .html.old files are now copied to .html
------------------
3 . Remove all backup files
rm *.old
No comments:
Post a Comment