I am trying to strip out certain characters from a string on both (left & right) sides. For example, line=see@hear|touch, i only want to echo the "hear" part. Well i have tried this approach:
line=see@hear|touch
templine=${line#*@} #removed "see@"
echo ${templine%%\|*} #removed "|touch"
hear
...apparently it worked but i want to do this in only one line. Can anyone suggest a way on how to do this?
Another question, what if i added some more characters like this:
line=see@hear|touch|smell
...now i wanted to separate each and every one of them dynamically* like this: (*the values for templine2, 3 & 4 may vary)
templine1=see
templine2=hear
templine3=touch
templine4=smell
...can anyone also suggest on this one?
Many thanks