Written by James McDonald

October 18, 2011

I want to extract the text “Windows 2008” sandwiched between [VM STORE] and “/Windows 2008.vmx”

So I need two field separators ] for the left and / for the right.

So for awk I use “[]/]” as the argument to -F.

Then I need to trim the spaces using sed.

echo "32     EDI Windows 2008          [VM STORE] Windows 2008/Windows 2008.vmx                             winLonghornGuest     vmx-07    EDI Data Integrator OS" | awk -F"[]/]" '{ print $2 }' | sed 's/^[[:space:]]*\(.*\)[[:space:]]*$/\1/'

Reference[1]: http://kirk.webfinish.com/2009/02/sed-script-to-trim-leading-and-trailing-spaces/

0 Comments

Submit a Comment

Your email address will not be published. Required fields are marked *

This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

The reCAPTCHA verification period has expired. Please reload the page.

You May Also Like…

Meraki Open Source Licenses

Until today I assumed that Meraki was built in-house with only closed source software. But having a look at the...

VEEAM FAILS

If you have Veeam backup failing with the Updating BCD failed with Cannot update SafeBoot flag and SentinelOne is...