I have been searching for a solution that allows me to search the lines of an array, and if a string match is made, push that line and the 2 previous lines into an array. It
You are mixing up the grep program /bin/grep with the perl function named grep (perldoc -f grep). While the former takes additional parameters, like -B, the latter does not.