The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com




View Single Post in the UNIX and Linux Forums - Click on the Thread or Permalink to View Entire Thread -->
  #3 (permalink)  
Old 07-01-2009
otheus's Avatar
otheus otheus is offline Forum Staff  
Moderator ala Mode
  
 

Join Date: Feb 2007
Location: Innsbruck, Austria
Posts: 1,886
Quote:
"Does anybody have some tips on understanding and mapping out the logic and flow of scripts"
First, you're rambling; get some sleep (if you can after 3 pots of coffee).

Second, "scripts" are usually executed in order the lines appear in the program, with the exception of things like loops. SH and derivatives (bash, zsh) handle functions, and these functions need to be defined before they are invoked. Other than that, it's pretty straight-forward.

*Sigh* then again, I've been coding since I was 10.

Third: You must understand Binary Logic (aka, Boolean Logic). The keys are understanding the basic operators: OR, AND, NOT. If you don't understand these correctly, you'll have a hard time. In most modern languages, including shell scripting, perl, and C, the operands can be expressions which means in the case of shell scripting, a program that returns an exit code.

So fourth, you have to understand that programs return exit codes. If the exit code is numerically 0, that means true. (0 for true is known sometimes as "negative logic").

If you are visually oriented, this tutorial might help.
I googled around and found this video which might help: YouTube - Prelude to Computer Science - 6: Binary Logic and YouTube - Prelude to Computer Science - 7: Logic Gates