Skip to content

Instantly share code, notes, and snippets.

@risyomei
Created September 25, 2019 08:09
Show Gist options
  • Save risyomei/f27179832fd8e81159ef66d1f13390de to your computer and use it in GitHub Desktop.
Save risyomei/f27179832fd8e81159ef66d1f13390de to your computer and use it in GitHub Desktop.
FILENAME=test.txt
MSG=$((ls $FILENAME) 2>&1);
ret=$?
re="name=(.*)"
if [ $ret -ne 0 ]; then
# 文件没有找到
echo $MSG >> err.log
echo "Error message written in err.log"
else
# 找到了文件
echo "File found:Starting Process"
for line in `cat $FILENAME`; do
if [[ $line =~ $re ]]; then
echo ${BASH_REMATCH[1]} >> stdout.log;
fi
done
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment