I am trying to build a list of files I didn't find before running a script. Like a pre-req checking.
CheckPrerequisite() {
matched=1
msg="Couldn't find"
    if ! [[ -f $path/file1 ]]; then
        msg=$msg"\n file1"
        matched=0
    fi
    if ! [[ -f $path/file2 ]]; then
        msg=$msg"\n file2"
        matched=0
    fi
    if ! [[ -f $path/file3 ]]; then
        msg=$msg"\n file3"
        matched=0
    fi
    if [[ matched -ne 1 ]]; then
        printf "$msg"
        exit
    else
        printf "***** Pre-requisites are met. *****"
    fi
}
Expected Output
Couldn't find
file1
file2
file3
Actual Output
Couldn't find\n file1\n file2\n file3
