shell脚本练习03--字符串

#########################################################################
# File Name: 9-4.sh
# Author: zhang yunabo
# mail: ma6174@163.com
# Created Time: Thu 13 Sep 2018 04:28:31 PM EDT
#########################################################################
#!/bin/bash
operation=macptopbm
suffix=pbm

if [ -n "$1" ]
then
        directory=$1
else
        directory=$PWD
fi

for file in $directory
do
        filename=${file%.*c}
        $operation $file > "$filename.$suffix"
        rm -f $file
        echo "$filename.$suffix"
done
exit 0

原文地址:https://www.cnblogs.com/zhangyuanbo12358/p/9643027.html