Lesson 2 - Create files, display contents and stats

dheeraj korangadheeraj koranga
1 min read
  1. touch:
  • Creates an empty file if it doesn’t already exist or updates the last modified timestamp of an existing file.

  1. dir:

    • Lists the contents of a directory, similar to the ls command. It's more common on Windows, but it also works in some Linux shells.

  1. echo:

    • Prints (echoes) a string of text or variables to the terminal. Often used to display messages or pass information to files or other commands.

  1. cat (>) file.txt

    • It is used to write content in it (note that it will re-write text into the file)

  1. cat ( to display the content)
  • Concatenates and displays the contents of files. It's commonly used to view the content of a file.

  1. cat (\>>) file.txt

    • It will append the text to the file

  1. head:

    • Displays the first few lines of a file (default is 10 lines). You can customize the number of lines with the -n option

  1. tail:

    • Displays the last few lines of a file (default is 10 lines). Useful for monitoring logs or files that are constantly updated.

  1. stat:

    • Displays detailed information about a file or file system, including size, permissions, creation/modification times, and more.

0
Subscribe to my newsletter

Read articles from dheeraj koranga directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

dheeraj koranga
dheeraj koranga