← Shell Scripting (Bash) learning path
Shell Scripting (Bash) · Module 8 of 10

Functions and text processing

Reuse code with functions and process text with sed and awk.

📖 Key ideas

  1. Functions: greet() { echo "Hi $1"; }.
  2. local keeps variables inside functions.
  3. sed edits streams: sed 's/old/new/g' file.
  4. awk processes columns: awk '{print $1}' file.
  5. find searches files: find . -name "*.jpg".
💡 Real-life example: sed is find-and-replace; awk is a mini spreadsheet for text columns.
FunctionReusable named block
localFunction-scoped variable
sedStream editor
awkColumn-based text processor