#!/bin/bash for i in `ls|egrep sh$` //用到egrep 正则匹配结尾为sh的 do mv $i `echo $i|cut -d. -f1`.txt //提取除了.sh前面的部分 字符串拼接.txt done