Re: [Nolug] yet more envar issues

From: Yuji Yamano <yyamano_at_kt.rim.or.jp>
Date: Wed, 16 Apr 2003 20:54:29 +0900 (JST)
Message-Id: <20030416.205429.92590007.yyamano@kt.rim.or.jp>

Hi Ron,

Ron Johnson <ron.l.johnson@cox.net> writes:

> bash sure is making things difficult...
>
> $ for f in "`ls -1 |grep ' '`";
> > do
> > x=`echo $f | tr ' ' '-'`
> > echo "@$f@ @$x@"
> > done
> @foo bar
> foo snafu@ @foo-bar-foo-snafu@
>
> What I want is:
> @foo bar@ @foo-bar@
> @foo snafu@ @foo-snafu@

Hmm, if you want to replace ' ' with '-', you can do it as follow:

$ for f in `ls | grep ' ' | tr ' ' '-'`; do echo "@$f@"; done
@foo-bar@
@foo-snafu@

For printing both original and new file names:

$ ls | grep ' ' | perl -ne 'chop; print "\@$_\@"; s/ /-/g; print "\t\@$_\@\n";'
@foo bar@ @foo-bar@
@foo snafu@ @foo-snafu@

Hope this help,

-- 
Yuji Yamano <yyamano@kt.rim.or.jp>
  The music spread everywhere. In the mouth. In the armpits. In the crotch.
  The music a way of flying up and flying past. --Susan Sontag
___________________
Nolug mailing list
nolug@nolug.org
Received on 04/16/03

This archive was generated by hypermail 2.2.0 : 12/19/08 EST