我想用选项卡分隔列生成日志文件。它应该有制表符分隔输出的格式如下,但所有的注释字段Linux命令以布局选项卡分隔列表很好
time date alias comment
10:09:20 03/06/13 jre This is a test comment
我使用csh历史的目的
set time = `perl -MPOSIX -e 'print POSIX::strftime("%T", localtime)'`
set date = `perl -MPOSIX -e 'print POSIX::strftime("%d/%m/%y", localtime)'`
set alias = jre
set comment = "This is a test comment"
配管我的文字column -t
echo "time\tdate\talias\tcomment" | column -t > somefile
echo "$time\t$date\t$alias\t$comment" | column -t >> tt
我几乎得到我想要的。但是,我的注释字段中的空格也会更改为制表符。有没有一种方法可以分隔前三个字段,但在评论字段中保持空间分隔?
感谢您的解决方案。我在csh中收到错误消息'Missing name for redirect',但没有在bash中。我认为这涉及到无关的空白字符。 csh是非常令人沮丧的 – moadeep
'bash -c paste <(echo -e“this \ tis \ ttab \ tseparated”)<(echo“This is your comment”)'窍门 – moadeep
很酷。很高兴你把事情解决了 :-) – Steve