使用 'cut' 命令获取列后自定义打印输出
Customizing print output after getting a column using 'cut' command
在执行打印出 table 的程序后,我正在尝试以 "customized" 的方式打印输出的第一列。我知道如何从输出中获取第一列,但我想在单引号之间打印每一行。所以,现在我有了可以让我进入第一列的命令:
./genTable | cut -f2 | xargs -0
我可以向该命令添加什么,以便它打印引号之间的值。例如,现在的输出看起来像
apple
cider
vinegar
我希望它看起来像
'apple'
'cider'
'vinegar'
我会使用 Perl。 ./genTable | perl -nwla -e 'print \'$F[1]\''
我会使用 awk
;-) ,即
./genTable | awk -v singleQ="'" '{print singleQ singleQ}'
当然,如果您想要极简主义,请将所有引用从 singleQ
更改为 Q
;-)
输出
'apple'
'cider'
'vinegar'
IHTH
在执行打印出 table 的程序后,我正在尝试以 "customized" 的方式打印输出的第一列。我知道如何从输出中获取第一列,但我想在单引号之间打印每一行。所以,现在我有了可以让我进入第一列的命令:
./genTable | cut -f2 | xargs -0
我可以向该命令添加什么,以便它打印引号之间的值。例如,现在的输出看起来像
apple
cider
vinegar
我希望它看起来像
'apple'
'cider'
'vinegar'
我会使用 Perl。 ./genTable | perl -nwla -e 'print \'$F[1]\''
我会使用 awk
;-) ,即
./genTable | awk -v singleQ="'" '{print singleQ singleQ}'
当然,如果您想要极简主义,请将所有引用从 singleQ
更改为 Q
;-)
输出
'apple'
'cider'
'vinegar'
IHTH