[질문] 쉘스크립트 질문 드립니다.

paeksj98의 이미지

안녕하세요.
쉘스크립트 질문 드립니다.
인터넷 검색해서 만들어 봤는데 자꾸 if조건으로 가네요.
if 조건에 맞는 파일이 없어서 then 조건으로 가거나 else조건으로 가야하는데
if조건에 들어가네요.

found=$(find /nand1/scan/ -name "test1" 2> /dev/null)
found2=$(find /nand2/ -name "test2" 2> /dev/null)            ==> nand2에 test2 파일이 있음.
if [ ! -z $found ]
  /nand1/scan/test1 -qws
then  [ ! -z $found2 ]       ==>요부분으로 해서 test2가 실행되어야 하는데....
  nand2/test2 -qws
else 
  insmod /lib/modules/g_file_storage_tcc79x.ko         ==> 요기를 실행하네요.
fi ; 

틀린 문법좀 지적부탁드립니다.
감사합니다.

ymir의 이미지

if 문은 다음과 같이 씁니다.

if [ condition] ; then
  statement;
elif [ condition ] ; then
  statement;
else
  statement;
fi

원래 문제의 경우에는, 다음처럼 하시면 될 것 같네요.

if [ -f /nand1/scan/test1 ] ; then
  /nand1/scan/test1 -qws
elif [ -f /nand2/test2 ] ; then
  /nand2/test2 -qws
else
  insmod /lib/modules/g_file_storage_tcc79x.ko
fi

되면 한다! / feel no sorrow, feel no pain, feel no hurt, there's nothing gained.. only love will then remain.. 『 Mizz 』

마잇의 이미지

if [ ! -z $found ]
  /nand1/scan/test1 -qws     <== 이 아이가 붕 뜬 것 같습니다. then 전에 나와서
then  [ ! -z $found2 ]


--
마잇