awk specifying multiple field separators

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/'



Submit a Comment

Your email address will not be published.

You May Also Like…


Zebra Printer Language The above website has a page where you can enter ZPL and it...

PHP Iterators

Just came across a Youtube talk "Iterators in PHP" by Jake Smith published in 2014 that steps through the many...

PHP array_map Multiple Arrays

array_map can take multiple arrays. I like how it starts mapping through them starting at the first element of each...