Re: Q: Help needed - works on Linux RH9 but not on a Solaris box

From: Ed Morton (mortonAVOIDINGSPAM_at_Lucent.com)
Date: 09/04/03


Date: Thu, 04 Sep 2003 11:11:07 -0500


On 9/4/2003 11:05 AM, Troll wrote:
> Thanks Joe.
>
> So change it to something like?:
> $variable = `echo $1 | grep -c "[^0-9+-]"`
> if $variable -gt 0

Don't forget the [ and ].

Alternative 1, still echo-ing and grep-ing:

echo $1 | grep "[^0-9+-]" > /dev/null
if [ $? = 0 ]

Alternative 2, no echo, no grep:

case "$1" in
        *[0-9+-]* ) echo good ;;
        * ) echo bad ;;
esac

Regards,

        Ed.



Relevant Pages

  • Re: OT: php question.
    ... Gary Kline wrote: ... I would suggest only echo-ing a line per file per hit and do a wc -l ... or echo the SCRIPT_FILENAME in a single file and do a grep ...
    (freebsd-questions)
  • Re: Sed command, Insert text in front of existing line
    ... > Heck, Joe, echo is even smaller: ... There's a section in the FAQ about why echo shouldn't be used to ... echo behaves inconsistently from shell to shell. ...
    (comp.unix.shell)
  • Re: Joe Magiera apearantly has been in an accident & is in the hospital.
    ... I echo that statement, and also hope that it is not true. ... Joe is one ... on a speedy recovery. ... have high score kits to prevent screen burn. ...
    (rec.games.video.arcade.collecting)
  • Re: wtwJoe 10/3
    ... been well at all and have had to spread myself a bit thin the past 10 ... Hi Joe, wish we could see more of you here, I miss you! ... Can I echo that?!! ...
    (uk.people.silversurfers)
  • Re: new mustang cobra
    ... Kate, you just made the top of my list today. ... I echo your sentiments 1000%. ... Gee, thanks Joe:) ...
    (rec.autos.makers.ford.mustang)