Q:

command line argument in shell scripting

HI all i am newbie to scripting, i am here with problem ,that i am not able to pass command line variable to my script .
biz$: ./myproject.sh -x file2

My(given) myproject has these contents:
 Type ="" //here i pass first argument
 while [ $# -gt 0]
 case "$1" in 
       -x)        shift; type = "x" >&2;shift ;;
       -y)        shift; type = "y" >&2;shift ;;
 ###################################################
 BEGIN{                            
       if ($7 == '/'){
           if ($2 != "zzzz"){
               printf ("error",$0);

           if ($3 < 111){
               printf ("error", $0);
         }

 file = " " //here i want to pass my argument file2.          

Please help me out to solve this, i am not able to move furthur without solving this, i am new guy to scripting. I cant cange $2 $3 $7..Experts pls i need your suggestion.

A:

I believe that you are using BASH and you want to obtain the command line parameters into two variable inside your script. In which case, the professional approach is to use 'getopts'
Please refer to this link : bash command line arguments for further details.

