Viewing Files with cat
cat — Concatenate and print
cat README.txt
cat documents/hello.txt
cat prints the entire file content to the terminal.
cat with multiple files
cat file1.txt file2.txt
Prints both files one after another.
Writing to files with cat
cat > newfile.txt
Type your content, then press Ctrl+D to save.
Appending with cat
cat >> existing.txt
Adds to the end of the file.
cat with line numbers
cat -n myfile.txt
For large files
cat prints everything at once. For big files, use:
less filename— scroll through pageshead filename— first 10 linestail filename— last 10 lines