Run Shell - grep pattern not matching Umlauts

59 views
Skip to first unread message

francwalter

unread,
May 15, 2023, 11:44:56 AM5/15/23
to Tasker
Hallo

I have some Tasks with (/system/bin/)grep, which I use in a Run Shell Action (without root).

I need to find words (for a scrabble word finder) in a textfile and I need some wildcards in the pattern.
The words are line by line, e.g.

AB,AB,1
ABU,BAU,2
...
BI,BI,94472
BO,OB,363425
BÜ,ÜB,587275
...

My grep command is this, e.g.:

grep "^B.," /path/to/wordlist.txt

but this does NOT find BÜ,..., only BI,... and BO,.... One dot does not find an Umlaut because they use two chars (UTF8) and the grep I use seems to be not aware of this.

Then I tried a lot other things, first I had the -E (for extended RegExp) parameter, but it does not change anything in such easy patterns.

Furhtermore I tried different wildcards, \w or \D or even [^,] (I still dont need the -E switch here!) or [A-ZÄÖÜ] but BÜ is never found.
Only with two dots: "^B..," but then grep finds words with 2 letters for the dot, which I dont want to find.

In Termux all this is working, also on my Ubuntu PC. I cannot use the Termux grep in Tasker, not working (when I use the whole path, because it is in Termux App-dir).

No change when I check "Use Tasker Settings" (yes, the Tasker Settings App is installed).
Only I get a message to contact the developer ;)

Is there maybe a different and working version of grep I could use?

Thanks, frank
I have Tasker 6.1.31 on Android 9 (without root).

francwalter

unread,
May 15, 2023, 3:06:57 PM5/15/23
to Tasker
I just tried the Termux Plugin (Termux:Tasker) and this works!

Configuration is:

Executable: /data/data/com.termux/files/usr/bin/grep (or just a Tasker variable)
Arguments (e.g.): "^B\w," /path/to/wordlist.txt (also Tasker variable possible)
(other options untouched).

Then I find in %stdout the result WITH Umlauts, e.g. BÜ,... BÖ,... etc.

So I would prefer to use the /system/bin/grep but if this is crippled, I will use Termux:Tasker.

francwalter

unread,
May 16, 2023, 5:51:29 AM5/16/23
to Tasker
That grep of my Android 9, /system/bin/grep is a real old version!
In Termux I can read:

~ $ /system/bin/grep -V
/system/bin/grep (BSD grep) 2.5.1-FreeBSD

This is very old! It was already old when Android 9 was new :(
And it is a crippled version of grep. In such moments I regret not to have root anymore.
The Termux grep version is 3.11 and the "real" grep, GNU grep ;)

I switched now my Run Shell Actions to Termux:Tasker Plugin and it works.

The big inconveniance now is, that I need Termux too, when I export my Tasks as App (with App Factory), which makes my App huge and that means, I cannot export it anymore as App :(

I still hope that there is maybe a native solution to my problem, that the system's grep could handle Umlaute and handle UTF8 correctly or at all.

Reply all
Reply to author
Forward
0 new messages