【发布时间】:2018-05-21 23:25:23
【问题描述】:
我正在尝试缩短进程启动的时间。 这是ps线。似乎由空格分隔。
casper@casperhost02 1065$ ps -ef | grep [t]xg casper 5345 1 34 16:40 ? 00:06:56 q /casper_apps/casper/reader/q/txg_dr.q -g 1 -w 80000 -p 3041 -taq /casper_apps/casper/data/fiofs/hdb0 -bin /casper_apps/casper/reader/q -t1 /casper_apps/casper/data/file -cmq /casper_apps/casper/common/q -ref /casper_apps/casper/static -prg txg_dr
我只想缩短 ps 行的时间并按字段提取.. 当我使用按空间切割和定界时,时间在第 10 场。
casper@casperhost02 1075$ ps -ef | grep [t]xg | cut -d' ' -f10
16:40
但是,当我使用 awk 时,它的 id 默认由空格分隔,它是字段 5。
casper@casperhost02 1076$ ps -ef | grep [t]xg | awk '{print $5}'
16:40
awk和cut中的字段分隔符有什么区别?
【问题讨论】:
-
awk默认情况下将所有连续的空白“挤压”到单个分隔符。