bug-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: make 'tr' (or something like it) a bash builtin ?


From: Stephane Chazelas
Subject: Re: make 'tr' (or something like it) a bash builtin ?
Date: Mon, 6 Feb 2006 08:34:34 +0000
User-agent: Mutt/1.5.6i

On Sun, Feb 05, 2006 at 07:02:10PM -0500, Chris F.A. Johnson wrote:
> On Sun, 5 Feb 2006, Felipe Kellermann wrote:
> 
> >On Thu, 2 Feb 2006 11:13pm  -0500, Mike Frysinger wrote:
> >
> >>upper case or lower case ... if 'tr' was a bash builtin, then that'd work
> >>with some `echo | tr` magic, but it something like
> >>${foo//[[:lower:]]/[[:upper:]]} would be nice
> >>-mike
> >
> >typeset -u (ksh, zsh) supported in bash would be nice...
> >
> > orchid% typeset -u fuu
> 
>    So long as it uses declare, not typeset :)
> 
> > orchid% fuu=bar
> > orchid% echo $fuu
> > BAR
> 
>    I'd prefer variable expansion, perhaps the way Mike suggested, or,
>    e.g.:
> 
> $ foo=bar
> $ echo ${foo^}  ## Convert first character
> Bar
> $ echo ${foo^^}  ## Convert all characters
> BAR
> $ echo ${foo^[a-m]} ## Convert first character that matches pattern
> Bar
> $ echo ${foo^^[a-m]} ## Convert all characters that match pattern
> BAr
[...]

Also note zsh parameter expansion flags that can be easily
combined:

$ foo=bar
$ echo ${(U)foo}
BAR
$ echo ${(Ul:20::.:)foo}
.................BAR
$ echo ${(Uqq)foo}
'BAR'

-- 
St├ęphane




reply via email to

[Prev in Thread] Current Thread [Next in Thread]