Grep for string and then output...

Hi all,

I have a file: /var/log/lct/buildinformation
I am trying to grep for string: MANUFACTURER : VMware, Inc.
If it contains the string I want to output the results of:

df -h |grep '/usr|/var' |awk '{print $6 " "$5}'

If it does not have the above string to send a no vm found
I have tried every iteration and I am getting every result but the one I need. Any help would be appreciated.

thanks
gartie

grep -q "MANUFACTURER : VMware, Inc." /var/log/lct/buildinformation && df -h | awk '/\/(usr|var)/ {print $6, $5} || echo "no vm found"'

Hi Aia,

it is not working...

thanks,

Gary

that was very helpful - thanks.
Based on my somewhat limited experience in these forums, providing a sample input and the desired output (using code tags) is the best approach.

1 Like

I translated your words to code, based on what you said. If you post example of real input and example of desired output, and perhaps the errors or undesired output your are getting now, I or someone else, might be able to help better.

My apologies - I replied too quickly...
what you supplied actually worked.
Once again my apologies.

Your initial post was not in CODE or ICODE tags, so the required string had lost the multiple spaces, hence why the suggestion did not work initially.

I have added the tags to your first post.