#!/bin/bash

# grab-if-conds
# expects a command-line argument that is a filename,
#    and attempts to grab lines from that file
#    with if in them and display
#    the conditions used in those if lines,
#    with the help of an RE and the BASH_REMATCH array
#
# by: Sharon Tuttle
# last modified: 2022-10-26

filename=$1
echo

while read next_line
do
    if [[ $next_line =~ if\ (.*)$ ]]
    then
        echo if line: "<${BASH_REMATCH[0]}>"
        echo its condition? "${BASH_REMATCH[1]}"
	echo
    fi
done < $filename