#!/bin/bash
# COMP 198  Spring 2026
# bash9.sh
# Count the number of .sh files in current directory

Nsh=0
while read A;                           # read into variable A
do
   echo $A | grep -i ".sh" > /dev/null  # we don't want to see the output here;
                                        # redirect it to the ether (stderr)
   if [[ "$?" -eq "0" ]];               # check status variable from grep; 
   then                                 # 0 indicates success (a match)
      let Nsh=$Nsh+1 
   fi
done < <(ls)                            # yikes; need exact spacing as shown; magic
# or done < $1                          # will read lines from a file instead

echo "Count of bash files is: $Nsh"
