#!/bin/bash path=. for file in $(ls $path) do if [ -f $file ] then filename=${file%.*} bak=${file#*.} if [ $bak == "$1" ] then mv $filename"."$1 $filename"."$2 fi fi done exit 0 执行:sh mv.sh sh doc