How to get the second column from command output?

后端 未结 8 1124
有刺的猬
有刺的猬 2020-11-29 18:08

My command\'s output is something like:

1540 \"A B\"
   6 \"C\"
 119 \"D\"

The first column is always a number, followed by a space, then a

相关标签:
8条回答
  • 2020-11-29 18:34

    This should work to get a specific column out of the command output "docker images":

    REPOSITORY                          TAG                 IMAGE ID            CREATED             SIZE
    ubuntu                              16.04               12543ced0f6f        10 months ago       122 MB
    ubuntu                              latest              12543ced0f6f        10 months ago       122 MB
    selenium/standalone-firefox-debug   2.53.0              9f3bab6e046f        12 months ago       613 MB
    selenium/node-firefox-debug         2.53.0              d82f2ab74db7        12 months ago       613 MB
    
    
    docker images | awk '{print $3}'
    
    IMAGE
    12543ced0f6f
    12543ced0f6f
    9f3bab6e046f
    d82f2ab74db7
    

    This is going to print the third column

    0 讨论(0)
  • 2020-11-29 18:36
    awk -F"|" '{gsub(/\"/,"|");print "\""$2"\""}' your_file
    
    0 讨论(0)
提交回复
热议问题