参考链接:https://blog.csdn.net/lyxleft/article/details/82222452
需求:遍历目录下的所有后缀为bin的文件,利用strings命令输出文件内包含的字符串。
for file in ./*
do
if [ "${file##*.}"x = "bin"x ]
then
filename=`basename $file`
temp_filename=`basename $file .bin`
suf=.txt
new_filename=${temp_filename}${suf}
echo "==========================================" >> ${new_filename}
echo $filename >> ${new_filename}
#cmd="awk '/AT/{print}' ${filename} >> ${new_filename}"
cmd="strings ${filename} > ${new_filename}"
eval $cmd
fi
# printf "no!\n "
done