如何格式化Bash Shell脚本的邮件输出 [英] How to format The mail Output of Bash Shell Script
本文介绍了如何格式化Bash Shell脚本的邮件输出的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个Bash shell脚本,该脚本每天在特定时间发送电子邮件。
的代码如下:
I have a Bash shell script which send an email in every day at certain time. the code is as follows:
first_dir=/test1 second_dir=/test2
email=me@me.com
allfiles=$(find /test1 /test2 -maxdepth 1 | sort) IFS=$'\n'
while true do sleep 24h
[ "$allfiles" != "" ] &&
find $allfiles -maxdepth 1 -printf '%Tc\t%s\t%p\n' |
mail -s "List Of All Files" "$email"
files="$allfiles"
done
此脚本在单列中提供输出。
,但我想在两列中输出。
This script is giving output in Single column. but I want the Output in two columns.
- 第一列,文件为first_dir = / test1
- 第二列,其中包含second_dir = / test2
推荐答案
它们像这样分开,不要放在第一位
If you want them separated like that, don't join them together in the first place
first_dir=/test1
second_dir=/test2
while sleep 24h; do
first_files=$(find $first_dir -maxdepth 1 -printf '%Tc\t%s\t%p\n')
second_files=$(find $second_dir -maxdepth 1 -printf '%Tc\t%s\t%p\n')
paste <(sort -t $'\t' -k 3,3 <<< "$first_files") \
<(sort -t $'\t' -k 3,3 <<< "$second_files") |
mail -s "List Of All Files" "$email"
done
这篇关于如何格式化Bash Shell脚本的邮件输出的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文