in reply to Playing with code found on Perlmonks

This could be rewritten:

fname=`echo $fname|sed 's/~/\/home\/ben/g'`

Perhaps:

fname=`echo $fname|perl -pe "s#~#$HOME#g"`
Steve
--

Replies are listed 'Best First'.
Re^2: Playing with code found on Perlmonks
by oko1 (Deacon) on Apr 17, 2008 at 00:01 UTC

    Oh - I hadn't realized we were golfing. In Unix, as in Perl, TMTOWTDI.

    # Bourne shell and derivatives fname=`eval echo $fname` # Modern shells (e.g., Bash) fname=${fname/\~/$HOME}

    Your turn, m'sieu? :)

    
    -- 
    Human history becomes more and more a race between education and catastrophe. -- HG Wells