grep 명령어 패턴에 변수를 넣을순 없나요?

dosun99v의 이미지

#!/bin/bash
 user1='dwarp'
 user2='rush'
 
 HOME=/var/log/center
 cd $HOME
 
 if [ -f userinfo.txt ]; then
   sudo rm userinfo.txt
 fi
 
 for file in *
   do
     if [ 'log_' = ${file:0:4} ]; then
       grep -w 'LOG IN-2 : ['$0078dh']' $file >> userinfo.txt
       grep 'LOG IN-2 : dwarp' $file >> userinfo.txt
     fi
done

스크립트 작성중 궁금한점이 있어서요
grep [옵션] [패턴] 파일명 이렇게 사용하는데요
grep 두번째 명령어에서 사용자 유저를 dwarp라고 직접 넣어줬느데
첫번째 명령어처럼 유저를 변수로 넣고 싶거든요..ㅠㅠ 잘 안되네요
초보가 여쭈어봅니다 ㅠㅠ

bacon의 이미지

grep "LOG IN-2 : ${user1}" $file >> userinfo.txt

dosun99v의 이미지

꾸벅(_ _)