You are not logged in.

#1 2013-06-12 22:11:31

tulek
Member
Registered: 2012-10-26
Posts: 4

[SOLVED] Need some assistance with "tr"

Hello Forum,

I'm trying to bypass the poor localisation the yahoo weather api has to offer.

I'm trying to set up a conky config in which the english weekday abbreviations are replaced by their german counter parts.

This is the code I have so far:


tr '[Mon,Tue,Wed,Thu,Fri,Sat,Sun]' '[Mo.,Di.,Mi.,Do.,Fr.,Sa.,So.]'

However: Thu is translated to Doo (instead of Do.)

I confess I'm not the most gifted shell expert, but I'm pretty sure there is a way to achieve my desired outcome.

By the way

tr '['Mon','Tue','Wed','Thu','Fri','Sat','Sun']' '['Mo.','Di.','Mi.','Do.','Fr.','Sa.','So.']'

doesn't help either.

A helping hand/hint would be really appreciated smile

Last edited by tulek (2013-06-12 22:26:02)

Offline

#2 2013-06-12 22:16:12

karol
Archivist
Registered: 2009-05-06
Posts: 25,427

Re: [SOLVED] Need some assistance with "tr"

You also get 'Doi' instead of 'Di'

Offline

#3 2013-06-12 22:18:05

tulek
Member
Registered: 2012-10-26
Posts: 4

Re: [SOLVED] Need some assistance with "tr"

karol wrote:

You also get 'Doi' instead of 'Di'

Yes, I know

The problem is: Tue and Thu are sharing quite a lot of letters wink

But there should be a way to search for the whole string/matching the string. At least I hope so.

Last edited by tulek (2013-06-12 22:19:10)

Offline

#4 2013-06-12 22:22:56

karol
Archivist
Registered: 2009-05-06
Posts: 25,427

Re: [SOLVED] Need some assistance with "tr"

I think it matches characters, not strings.

Offline

#5 2013-06-12 22:24:21

progandy
Member
Registered: 2012-05-17
Posts: 2,151

Re: [SOLVED] Need some assistance with "tr"

use sed.

sed "s/Mon/Mo/g;s/Tue/Di/g;s/Wed/Mi/g;s/Thu/Do/g;s/Fri/Fr/g;s/Sat/Sa/g;s/Sun/So/g"

Last edited by progandy (2013-06-12 22:24:51)

Offline

#6 2013-06-12 22:27:37

tulek
Member
Registered: 2012-10-26
Posts: 4

Re: [SOLVED] Need some assistance with "tr"

Thanks,

That worked, I've experimented with sed but couldn't wrap my head around it.

Edit: Is there a "mark thread as solved button", can't find it?

Last edited by tulek (2013-06-12 22:28:26)

Offline

#7 2013-06-12 22:54:44

karol
Archivist
Registered: 2009-05-06
Posts: 25,427

Re: [SOLVED] Need some assistance with "tr"

tulek wrote:

Is there a "mark thread as solved button", can't find it?

Nope: https://bbs.archlinux.org/viewtopic.php?id=130309

Offline

Board footer

Powered by FluxBB