Return all output columns only if the content in the second column is positive
I am looking for a way to return a string only if the second column returns a positive number value. In the example below ...
PID Status Label
- 0 com.apple.CoreAuthentication.daemon
937 0 com.wacom.TabletDriver.126696
- 0 com.apple.quicklook
- 0 com.apple.parentalcontrols.check
715 48 com.apple.Finder
- 0 com.apple.PackageKit.InstallStatus
- 0 com.apple.FontWorker
786 -44 com.apple.bird
- 0 com.apple.familycontrols.useragent
- 0 com.apple.aos.migrate
- 0 com.apple.universalaccessAuthWarn
839 -44 com.apple.nsurlsessiond
I need a command that will result in:
PID Status Label
715 48 com.apple.Finder
I am pulling my hair out trying to find a way to do this through AWK, SED, GREP, RegEx, etc. I cannot get the results I want.
I've tried things like:
launchctl list | awk '{for (i=1;i<=NF;i++) if ($i>=1) print $i} '
but the results are no longer in the table and are returned in an unreadable format, and I also get positive numbers back from the PID / $ 1 column when I would only like to get results if Status / $ 2.
Starting from launchctl list | awk '{ print $2 }'
, but if I pass it through something else like GREP / SED, I obviously can't get the other missing columns as the data has already been deleted. I am not an expert and perhaps I am just missing the keystream. through | to get what I want, so I ask for any help or experience to help point me in the right direction.
source to share