Anzeige
Anzeige

Más contenido relacionado

Anzeige

Último(20)

Lab 7 - Bash Script.pptx

  1. Lab 7 – Bash Script CIE 302 - Operating systems
  2. What is bash scripting? Bash script: a plain text that contains a series of commands, which can be used to write Linux commands in the terminal. Anything you can run normally on the command line can be put into a script and it will do exactly the same thing. Bash scripts an extension of .sh (myscript.sh). However, Linux is an extensionless system so a script doesn't necessarily have to have this characteristic in order to work.
  3. How to execute a bash script?  ./script → it will execute the script file, as a new child process within the bash/terminal.  to grant permissions, to execute file: chmod 755 script1 ⇔ (rwxr-xr-x) The file's owner may read, write, and execute the file. All others may read and execute the file.
  4. Script format #!/bin/bash ⇔ The first line in code, must start with “#!”. # A sample Bash script ⇔ comment line, not executed. echo Hello World! ⇔ actual command that could be directly written in the terminal.
  5. Variables To declare a variable: $a, $A, $a1A. To initialize a variable  a=4 To display the variable and its value  echo $a Variable substitution var='Hello Student' text=" $var Ahmed" echo $text
  6. If statements
  7. If statements
  8. For loop
  9. While loop
  10. Functions To declare a variable: $a, $A, $a1A. To initialize a variable  a=4 To display the variable and its value  echo $a Variable substitution var='Hello Student' text=" $var Ahmed" echo $text
Anzeige