jed*_*rds 15
打印第一栏*:
<some output producing command> | awk '{print $1}'
Run Code Online (Sandbox Code Playgroud)
打印第二栏:
<some output producing command> | awk '{print $2}'
Run Code Online (Sandbox Code Playgroud)
等等
哪里<some output producing command>
像cat filename.txt
或echo $VAR
等
例如,ls -l | awk '{print $9}'
提取第九列,这就像......尴尬的方式ls -1
*列由分隔空格定义.
编辑:如果您的文本已经在变量中,例如:
VAR2=$(echo $VAR | awk '{print $9}')
Run Code Online (Sandbox Code Playgroud)
如果您将9更改为所需列,则可以正常工作.