I have a string as below
colors="BD0 BLUE|BD1 RED|BD2 YELLOW |BDX PINK"
Now I need to search for BD2 in the string and get the value Yellow, or BD0 and get BLUE
How can I do this using unix script using awk or sed?
I know we can store as key value pairs in perl, is there any way we do this in Unix also, so that I can store the above values as key values instead of string?