Split output of command by columns using Bash?

前端 未结 10 865
遥遥无期
遥遥无期 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:31

    Instead of doing all these greps and stuff, I'd advise you to use ps capabilities of changing output format.

    ps -o cmd= -p 12345
    

    You get the cmmand line of a process with the pid specified and nothing else.

    This is POSIX-conformant and may be thus considered portable.

提交回复
热议问题