[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: make 'tr' (or something like it) a bash builtin ?
From: |
William Park |
Subject: |
Re: make 'tr' (or something like it) a bash builtin ? |
Date: |
Sun, 5 Feb 2006 22:02:23 -0500 |
User-agent: |
Mutt/1.4.2.1i |
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
Options are already overloaded. I could never remember what is what.
>
> 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
I did that, and subsequently removed it because I ran out of
punctuation. :-)
--
William Park <opengeometry@yahoo.ca>, Toronto, Canada
ThinFlash: Linux thin-client on USB key (flash) drive
http://home.eol.ca/~parkw/thinflash.html
BashDiff: Super Bash shell
http://freshmeat.net/projects/bashdiff/