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…