Linux Labs

Bash: text processing and scripts / Stage 4 of 9

A script is a file of commands

Not running Starting usually ~20 s
Leave the lesson

Step 6 of 6 · summary · 2 min

Summary

  • A script is a text file of commands, and an interpreter carries it out. bash file names the interpreter explicitly, ./file takes it from the shebang, and sh file on Ubuntu is dash, which does not know bash syntax.
  • Running a file as a program requires the x permission. A name without / is looked up only in PATH, so your own commands go into ~/bin.
  • A variable is name=value with no spaces around =. Expand it in double quotes, "$name", or a space will split the value into pieces.
  • At the start of the lesson ./ ran into the missing x permission, the bare name into a PATH without the current directory, and sh into a bracketed list that only bash understands.
Ubuntu 24.04
Loading…