M*******n 发帖数: 508 | 1 【 以下文字转载自 Linux 讨论区 】
【 原文由 MildSeven 所发表 】
怎么用shell语言把一个目录下的.txt文件后缀名变为.dat?
多谢 |
r*****s 发帖数: 985 | 2 ls *.txt | sed 's/\(.*\)txt/mv & \1dat/' | sh
【在 M*******n 的大作中提到】 : 【 以下文字转载自 Linux 讨论区 】 : 【 原文由 MildSeven 所发表 】 : 怎么用shell语言把一个目录下的.txt文件后缀名变为.dat? : 多谢
|
c****r 发帖数: 185 | 3 for i in `ls *.txt`; do mv $i ${i/.txt/.dat}; done
【在 r*****s 的大作中提到】 : ls *.txt | sed 's/\(.*\)txt/mv & \1dat/' | sh
|
r****d 发帖数: 375 | 4 find . -name '*.txt' -print | while read file; do mv $file ${file%.*}.dat;
done
This one finds all the txt files in the directory/sub_directories.
【在 c****r 的大作中提到】 : for i in `ls *.txt`; do mv $i ${i/.txt/.dat}; done
|