BASH:replace text in files by sed
#!/bin/sh
TAG="aa:1234\/"
DST="aa\/"
for a in `find . -name '*.txt' -type f`
do
c=`cat ${a} | grep ${TAG}`
reg=".*${TAG}.*"
if [[ "${c}" =~ $reg ]] ; then
cat ${a} | sed "s/${TAG}/${DST}/g"
fi
done
浙公网安备 33010602011771号