Experts Exchange connects you with the people and services you need so you can get back to work.
L1=$(grep -n "$STRING1" $FILE |cut -f1 -d":")
if [[ ! -z $L1 ]] ; then
L2=$(grep -n "$STRING2" $FILE |cut -f1 -d":")
if [[ ! -z $L2 ]] ; then
if [[ $(($L2 - $L1)) -eq $DISTANCE ]] ; then
echo "SUCCESS! $STRING1 found at line $L1, $STRING2 found at line $L2"
else echo "$STRING1 ($L1) and $STRING2 ($L2) found, but distance is not $DISTANCE lines!"
else echo "$STRING1 found, but $STRING2 not found!"
else echo "$STRING1 not found!"
Open in new window
Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.
Have a better answer? Share it in a comment.
Please enter a first name
Please enter a last name
Must be at least 4 characters long.
Join and Comment
Be seen. Boost your question’s priority for more expert views and faster solutions