shell.sh 파일명 (파일을 변수처리할때)

help@osori.org의 이미지

아주 기본적인 질문인지 모르겠으나.. 사용해 본적이 없어서;;

일단 작성해본 소스는 이렇습니다.

#!/bin/bash
 
echo ""
echo "################### Access Log Check now ####################"
echo ""
 
if [ -z $1]; 
 
then
 
ERRORLIST=`awk '{print $3}' $1 | sort -u`
        for LIST in $ERRORLIST
        do
                ERRORCODE=`tail -1 $LIST | awk '{printn $2}'`
                echo "Error Code  $ERRORCODE list is -> $LIST"
                echo -n "error total is -> "
                awk '{print $0}' $1 | grep $LIST | wc -l
                echo ""
        done
 
else
        echo "Log not found."
fi

참조될 파일명은 imsi 내용은 아래와 같습니다

[root@Asianux2 ~/bin]# cat imsi
[01/Sep/2007:08:32:14   403     /fx/PriceMall/bin/PriceMain.swf
[01/Sep/2007:08:33:29   403     /fx/PriceMall/bin/test.swf
[root@Asianux2 ~/bin]# 

원하는것은 프롬프트 상에서 test.sh ./imsi 라고 실행하면 결과값이 나오는것입니다.

이런 기법을 파일의 파라메터화 라고 하나요? 잘 모르겠지만 무튼 이런 과정을 구현하고 싶습니다.

조언좀 해주세요 --;

현재는 에러가 나오네요;;

[root@Asianux2 ~/bin]# test.sh imsi
 
################### Access Log Check now ####################
 
/root/bin/test.sh: line 7: [: missing `]'
Log not found.
[root@Asianux2 ~/bin]#