Working With Programs: Takeaways: Syntax
Working With Programs: Takeaways: Syntax
Syntax
• Assign a variable
OS=Linux
OR
OS="Linux"
• Print a variable
echo $OS
print(os.environ["LINUX"])
Concepts
• A shell is a way to access and control a computer.
• Bash is the most popular of the UNIX shells, and the default on most Linux and OS X computers.
• Command line shells allow us the option of running commands and viewing the results, as
opposed to clicking an icon in a graphical shell.
• Quotations around strings in Bash are optional, unless they contain a space.
• We can set variables on the command line by assigning values to them.
• In the command line environment, variables consist entirely of uppercase characters, numbers,
and underscores.
• Environment variables are variables you can access outside the shell.
• We can run many programs from Bash, including Python.
• os.environ is a dictionary containing all of the values for the environment variables.
• Programs are similar to functions, and can have any number of arguments.
• Programs can also have optional flags, which modify program behavior.
• We can chain multiple flags that have single, short, character names.
Resources
• UNIX Shells
• Environment Variables