Friday 15 February 2013

bash - Different syntax for if in shell script -


I am learning shell script and I'm getting different syntax for shell script conditional statement. Does the CST script have a different syntax than the TCP script? Some say

  if ["$ PASSWORD" == "$ VALID_PASSWORD"]; Then "you have access" echo! And "Access denied" echo! Fi   

some use

  if you have "have access" ($ PASSWORD == $ VALID_PASSWORD) echo! And "Access denied" echo! I tried my own and I got errors like "if: empty if" or "if: expression syntax" and these messages are too brief to understand. So I asked the method of solving these issues and there are different solution based on shell (CSS, TCS)  

If my wine is TCS, then I always want a TSPSP script or I can write Bash script.

csh and tcsh For a if statement:

  if (expr) then ... else if (expr2) then ... else ... endif  < / Pre> 

Your other example (perhaps) to sh or bash :

  if there is a list; Then the list; [Alif list; Then the list; ] ... [other list; ]   

Where there is an invocation to your list program (or sometimes shell made), [.

You can type a script, whatever the shell you want, as long as you have the correct

  #! / Bin / sh #! / Bin / bash #! / Bin / csh #! / Bin / tcsh   

Match the desired shell of your script at the top of the file.

No comments:

Post a Comment