Split output of command by columns using Bash?

前端 未结 10 879
遥遥无期
遥遥无期 2020-12-23 02:46

I want to do this:

  1. run a command
  2. capture the output
  3. select a line
  4. select a column of that line

Just as an example, l

10条回答
  •  鱼传尺愫
    2020-12-23 03:23

    Similar to brianegge's awk solution, here is the Perl equivalent:

    ps | egrep 11383 | perl -lane 'print $F[3]'
    

    -a enables autosplit mode, which populates the @F array with the column data.
    Use -F, if your data is comma-delimited, rather than space-delimited.

    Field 3 is printed since Perl starts counting from 0 rather than 1

提交回复
热议问题