Hi all, i am new to shell scripting and know very few basics, i have a shell script program written by some other guy and i am trying to understand it. I am unable to understand a few parts of the program, hope some one cud help me with this ....

while [ "$?" = "0"  ]
  do
     if [ "$var" ]
     then
        echo "get /somepath/$value/$var /somepath/$var" >> testfile1.txt
     fi
     read var
  done < testfile2.txt

In the while loop what does $? mean and will it not go to an infinite loop, in the echo statement, what does get do, i guess "read var" reads a value from keyboard right, and finally what does done < testfile2.txt mean .....

Hope some one helps and thanks for your help ...

$? is variable in which the exit status of the last command is stored.

0 - Sucessful execution of command
1 - Error

The importance of this variable in shell scripting is that

"In a shell script, the error message is ignored and the script continues to execute. For this reason, it is necessary to check whether a program exited successfully."

Hope this helps.

Amit

Thanks for your reply amit, can u even tell me what does this mean

"done < testfile2.txt" and
what does a "get" do in the shell script ...

Thanks for your time and appreciate it ....

i hope u got the answer to your queuries. You can find these commands with their explanation in any of the unix manuals.

Try out the tutorial listed at the top of this forum "Bourne / Bash Unix/Linux shell scripting tutorial". You will get answer of all your problems because these are the very basics of shell scripting

Amit