OPS235 Scripting Exercises

From CDOT Wiki
Revision as of 11:58, 10 January 2020 by Andrew (talk | contribs) (Created page with "= Things you need to know = == Terminal vs script file == A shell script is nothing more than a sequence of shell commands. Any command you put in a shell script can be exec...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Things you need to know

Terminal vs script file

A shell script is nothing more than a sequence of shell commands. Any command you put in a shell script can be executed just as well in a terminal. In fact no matter how complex your script is - you can run the entire thing from a terminal window without executing the script.

Runnning a command

  • How to run a command in the current directory or another directory or a directory in the $PATH
  • That programs you run need to have execute permission
  • What your $PWD is, pwd command
  • Check the return code from a command by examining $?

Variables

  • How to create a variable and set a value in it
  • How to get the value from a variable

Quotes

  • Why use single or double quotes
  • The difference between single and double quotes
  • Backquotes

Redirecting output

  • How to redirect output from a command to a file
  • How to pipe output from one command to another command

Exercises