Shell echo语句输出



我是shell脚本的新手。我有以下shell脚本-

psql database connection -t -c "SELECT bucket FROM all_buckets GROUP BY bucket" | while read bucket_var ; 
do
if [ ! -z "$bucket_var" ]
then
echo "Bucket being processed is - $bucket_var"
fi
done

这是我得到的输出-

+ '[' '!' -z Endography ']'
+ echo 'Bucket being processed is - Endography'
Bucket being processed is - Endography
+ read bucket_name_var

如何得到这个输出-

Bucket being processed is - Endography (current date and time in CST) 

看起来您的脚本中有set -x。这使得它在执行命令时回显所有命令。删除该行(或执行set +x撤消设置)。

摘自setman页:

-x在展开每个简单命令(for command、case command、select command、arithmetic for command)后,显示PS4的展开值,后面是该命令及其展开参数或相关的单词列表。

添加当前日期和时间,使用date:

echo "Bucket being processed is - $bucket_var ($(date))"

相关内容

  • 没有找到相关文章

最新更新