Chinaunix

标题: Backup all files in directory [打印本页]

作者: dow    时间: 2009-04-20 21:40
标题: Backup all files in directory
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'

本文来自ChinaUnix博客,如果查看原文请点:http://blog.chinaunix.net/u1/40227/showart_1904832.html




欢迎光临 Chinaunix (http://bbs.chinaunix.net/) Powered by Discuz! X3.2