The command below can be used to backup all files in a directory
IFS=$'\n';for file in *; do cp ${file}{,.bak}; done |
Quick explanation:
1. Set IFS - This allows for files with spaces in their name.
2. Use all files (*) - Change this to only backup certain files.
3. Use expansion to copy each file from 'filename' to 'filename.bak'
阅读(1135) | 评论(0) | 转发(0) |