我正在写一个 bash 脚本。它运行几个 grep 命令,并将 grep 命令的输出记录在文本文件中。我得到了输出,但它没有格式化,所以很难阅读。任何我可以用来格式化/美化输出的建议,将不胜感激。目前的脚本是:
validateError=$(grep {some command} / -1)
echo ${validateError}\n | sudo tee -a ./validation_logs/${hostname}_result.log
echo "----------------------------\n" | sudo tee -a ./validation_logs/${hostname}_result.log
echo "grep -B 3 'ps -eaf|grep -i snitch' ${hostname}_result.log\n" > ./validation_logs/${hostname}_result.log
validateProcess=$(grep {somecommand} / -1)
echo ${validateProcess}\n | sudo tee -a ./validation_logs/${hostname}_result.log