【问题标题】:tabulated output with carriage return with jq带回车的表格输出和 jq
【发布时间】:2021-04-13 08:04:10
【问题描述】:

我正在尝试使用 jq 获得表格输出,但我无法获得完美的对齐方式。见:

$ ./Error_CLIENT.sh | /home/USER/jq -rj '.[] | .job.Name, "\t\t" ,.Atrributes.userData, "\n"'
HOME22          pte
HOME23          pte
HOUSEABI                pdt all
HOUSEAB2                pdt all
....

我想得到:

HOME22                  pte
HOME23                  pte
HOUSEABI                pdt all
HOUSEAB2                pdt all
.......

你知道这是否可能吗?谢谢

【问题讨论】:

    标签: json jq tabular


    【解决方案1】:

    只有 jq 的解决方案当然是可能的,但几乎可以肯定的是,将 jq 的 @tsvcolumn -tpr -e 结合使用会更容易;参见例如Replace tab with variable amount of spaces, maintaining the alignment

    【讨论】:

    • 我正在尝试这些:./Error_CLIENT.sh | /home/USER/parser -rj '[.[] | .job.Name, "\t\t" ,.Atrributes.userData, "\n"] |@tsv' 但它让我明白了: HOME22 pte \n HOME23 pte \n HOUSEABI pdt all \n HOUSEAB2 pdt all \n 。 ..它向我显示字符文字“\n”
    猜你喜欢
    • 1970-01-01
    • 2023-01-28
    • 2021-07-18
    • 2013-03-02
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多