[Subject Prev][Subject Next][Thread Prev][Thread Next][Subject Index][Thread Index]
Re: Newbie - shell program problem
On Sun, 29 Oct 2000, YL Narayana wrote:
> --------Program---------
> #!/bin/bash
>
> function CountMatches {
> MATCHES = `ls -d $1 2>/dev/null | wc -l`
There should be no spaces after MATCHES. is
MATCHES=`ls -d $1 2>/dev/null | wc -l`
> echo "$MATCHES"
> if [ $MATCHES != 0 ] ; then return 0 ; else return 1 ; fi
> }
>
> function DispMatches {
> if MATCHES=`CountMatches "$1"` ; then
> echo -n "Number of matches for $1: "
> echo $MATCHES
> else
> echo "$1 is not a valid pattern."
> fi
> }
>
> DispMatches '/dev/hda*'
> DispMatches '/proc/*'
> DispMatches '/foo/*'
>
The output on my box after the above change:
Number of matches for /dev/hda*: 17
Number of matches for /proc/*: 103
/foo/* is not a valid pattern
(I don't have a /foo directory :-)
Bye and Enjoy Life...
--
#!!! If anything can go wrong, _FIX_ it. (To hell with MURPHY)
Ajay kumar Dwivedi
ajayd@xxxxxxxxxx