humingcheng / study_notes

The only significance of notes is to reduce the cost of acquiring knowledge.
0 stars 0 forks source link

批量文件操作 #9

Open humingcheng opened 8 years ago

humingcheng commented 8 years ago

例如对多个文件进行读写、删除、压缩、转格式等。

以dos2unix为例

1,将目录中的所有文件转换格式 find /opt/test/ -type f -exec dos2unix {} \; #必须有分号 2,目录中的.c和.h文件 3,将目录中的所有文件转换格式,除了.html文件 4,将目录中的所有文件转换格式,除了子目录dir1,dir2。 5,将dir1,dir2...dirn目录中的所有文件转换格式 批量文件操作,例如压缩、删除、转换格式等。这些都可用find命令配合具体的命令来以rm命令为例

find /opt/test/ -type f -exec dos2unix {} \; #必须有分号 find也支持正则