Week 5 – Redirections and Read/Write to Files

I. Redirections in bash commands

  • stdin (standard input): This stream is used for input, such as keyboard input or input from a file.
  • stdout (standard output): This stream is used for output, such as the results of a command or the contents of a file.
  • stderr (standard error): This stream is used for error messages and other output that is not intended to be the primary output of a command.

II. Simple filter commands

  • head: Prints the first few lines of a file or output.
  • tail: Prints the last few lines of a file or output.
  • cut: Extracts specific fields from the output of a command.
  • sort: Sorts the output of a command.
  • tr: Translates or deletes characters in the output of a command.
  • wc: Counts the number of words, lines, or characters in the output of a command.

III. grep utility

IV. Redirection and piping

  • Redirection: This allows you to redirect the output of a command to a file or to another command.
  • Piping: This allows you to chain multiple commands together and pass the output of one command as the input to another command.

V. /dev/null file

 

License

Developers ultimate guide: Linux Bash scripting Copyright © 2022 by Matin Maleki. All Rights Reserved.

Share This Book