0

dokku ls shows the following but how can I get the status of app-1470418443 using awk for example ?

So that magic command returns running.

-----> App Name           Container Type            Container Id              Status                   
app-1470418443            web                       78a092d176f1              running                  
example                   web                       3b7803c49e04              running                  
example2                  web                       a750f2b4be44              running
Alex. b
  • 669
  • 2
  • 10
  • 18
  • Possible duplicate of [grep for contents AFTER pattern](http://stackoverflow.com/questions/10358547/grep-for-contents-after-pattern) – tripleee Aug 06 '16 at 09:19

2 Answers2

2
awk '$1=="app-1470418443"{print $NF}'
Ed Morton
  • 188,023
  • 17
  • 78
  • 185
0

Since there is trailing space in the example output you have to get all non-space characters ([^ ]*) and then all the space (_*, underscore _ represents space as space didn't render at all) in the end of the string ($) and print only the matching parts (grep -o):

$ grep "^app-1470418443 " file | grep -o "[^ ]* *$"
running

Without trailing space, the latter grep would simplify a bit (well 2 bytes) to match only the non-space chars:

$ grep "^app-1470418443 " file | grep -o "[^ ]*$"
running
James Brown
  • 36,089
  • 7
  • 43
  • 59