[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: make 'tr' (or something like it) a bash builtin ?
From: |
Chris F.A. Johnson |
Subject: |
Re: make 'tr' (or something like it) a bash builtin ? |
Date: |
Sun, 5 Feb 2006 19:02:10 -0500 (EST) |
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
--
Chris F.A. Johnson <http://cfaj.freeshell.org>
===================================================================
Author:
Shell Scripting Recipes: A Problem-Solution Approach (2005, Apress)