Bash =~ operator and tab characters

Johnny Rosenberg gurus.knugum at gmail.com
Fri Apr 22 21:55:46 UTC 2016


Hi. I'm kind of struggling with this one.

I need to check a lot of strings for the following:
TAB ( <at least 4 and not more than 10 numbers or minuses> ) TAB

I tried a lot of variations, I don't even remember them all, but here's one
of them:
if [[ ${Rows[$i]} =~ \t[0-9\-]{4,}\t ]]; then
# Do something
fi

But so far with no success.
It SEEMS like the \t doesn't mean the TAB character, but that's not much
more than a guess.
What I'm looking for in those strings are a date in parentheses, preceded
by a TAB and superseded by a TAB. If I now let ↹ represent the TAB
character and … represent any characters, here are the possible strings I
am trying to look for with that if statement:
…↹(2016)↹…
…↹(2016-04)↹…
…↹(2016-04-22)↹…

Any thoughts?
I have done some searching but I always end up with too many hits, and so
far all of those I looked further into were totally irrelevant, as far as I
could see.


Kind regards

Johnny Rosenberg
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.ubuntu.com/archives/ubuntu-users/attachments/20160422/c63a50f2/attachment-0001.html>


More information about the ubuntu-users mailing list