On Mon, Jul 31, 2000 at 04:10:43PM -0400, Mike A. Harris wrote:
> Is there an easy way using bash INTERNALS to do the following:
> 
> Read in a file containing two numbers on one line separated by
> space, and replace the whitespace between them with a ":"?
> 
> I'm trying to optimize some stuff in a script and trying to get
> rid of awk/sed/perl calls that are unnecessary.
> 
> The input file contains:
> 
> 2345 5678

try something like this:

$ zz="2345        5678"
$ echo ${zz%% *}:${zz##* }
2345:5678

I tried fiddling with tabs in the whitespace but couldn't figure it
out, so I don't know if that will work or not. If it's just spaces,
this might work for you.

The '%%' deletes everything that matches the pattern (in this case, a
space followed by anything) from the end of the variable's value.

The '##' does the opposite: deletes anything (followed by a space)
from the beginning of the variable's value.

HTH

HAND

Fred

-- 
"The philosophy that everyone started to put forth was 'Write programs that do
one thing and do it well. Write programs to work together. Write programs that
handle text streams, because that is a universal interface.'" -- Bell Labs, the
Creation of the UNIX Operating System



_______________________________________________
Redhat-devel-list mailing list
[EMAIL PROTECTED]
https://listman.redhat.com/mailman/listinfo/redhat-devel-list

Reply via email to