批量建立文件并修改后缀名

目的:批量建立文件,并修改后坠名bash

1,批量产生 *.txt文件.net

[root@Redhat7 file]# for i in {1..100}
> do
> touch $i.txt
> doneget

2,把.txt文件所有改为.docclass

[root@Redhat7 file]# cat ChName.sh
#!/bin/bash
for i in `ls *.txt`
do
    mv $i ${i%.*}.doc
done变量


总结: 此脚本需用到变量的掐头去尾,先把txt给掐掉,来到达更改变量的目的file

掐头
echo ${变量#*:}
去尾
echo ${变量%:*}总结

相关文章
相关标签/搜索