Lesson 2 - Create files, display contents and stats
dheeraj koranga
1 min read
touch
:
- Creates an empty file if it doesn’t already exist or updates the last modified timestamp of an existing file.
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.
- Lists the contents of a directory, similar to the
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.
cat
(>
) file.txt- It is used to write content in it (note that it will re-write text into the file)
cat
( to display the content)
- Concatenates and displays the contents of files. It's commonly used to view the content of a file.
cat
(\>>) file.txt- It will append the text to the file
head
:- Displays the first few lines of a file (default is 10 lines). You can customize the number of lines with the
-n
option
- Displays the first few lines of a file (default is 10 lines). You can customize the number of lines with the
tail
:- Displays the last few lines of a file (default is 10 lines). Useful for monitoring logs or files that are constantly updated.
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