我正在编写一个小型预算脚本来关注我的财务状况。我想记录下所有交易及其发生时间的日志。
目前,我将支出作为参数输入:
f)
echo "$OPTARG spent on food" | tee spendinglogs.log
... # take away money from monthly budget
echo "$REMAINING_FOOD_BUDGET remaining" | tee spendinglogs.log
m)
echo "$OPTARG spent on miscellaneous" | tee spendinglogs.log
... # take away money from monthly budget
echo "$REMAINING_MISC_BUDGET remaining" | tee spendinglogs.log
... #etc
我不想将输出内容的时间戳显示在终端,但我希望在日志中记录输出的时间戳。有没有方法可以实现这个功能?
例如:
echo "$OPTARG spent on food" | tee `date %d-%m-%y %H_%M_%S` spendinglogs.log
但我无法想象那样做会起作用。
ts
是一个很好的工具。到目前为止,我只使用awk
来进行时间戳记录。+1 - anishsane