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…

Squarespace Image Export

To gain continued access to your Squarespace website images after cancelling your subscription you have several...

MySQL 8.x GRANT ALL STATEMENT

-- CREATE CREATE USER 'tgnrestoreuser'@'localhost' IDENTIFIED BY 'AppleSauceLoveBird2024'; GRANT ALL PRIVILEGES ON...

Exetel Opt-Out of CGNAT

If your port forwards and inbound and/or outbound site-to-site VPN's have failed when switching to Exetel due to their...