Let's say I'd like to remove the first two and last three characters from all elements of an array e.g.
results=( QK9H9UtADCgnG AlaLkCADjQ krsxseW8H1VrU 6nBG94ZbCWQ )
I'd like to end up with
results=( 9H9UtADC aLkCA sxseW8H1 BG94Zb )
other than looping over the elements and using ${element:2:-3}
is there a flag or some sort of combination that allows doing something like ${(⭕)results:2:-3}
so that substring expansion affects every element instead of affecting the array?
If it matters, in my particular case, the arrays can never have empty elements, elements can not contain any sort of white-space characters and the extraction rule is always L>P+S that is the Length of any element is always greater than the combined length of the Suffix and Prefix that are to be removed.
I'm not interested in rev-ing strings and using text processing tools. I'm currently using a function to loop as I said above, so this isn't a matter of trying to type less, I was just curious if it's possible as I went through the manual and couldn't find a way to do it.
map
,reduce
andfilter
? Maybe this: github.com/timonson/bashFunc