The cat command has several useful options and uses beyond just displaying file contents. Here are some common ones:
-
Concatenate Files:
You can combine multiple files into one:cat file1.txt file2.txt > combined.txt -
Create a New File:
You can create a new file and write text to it:cat > newfile.txt(Type your text and press
CTRL+Dto save.) -
Append to a File:
You can add content to an existing file:cat >> existingfile.txt(Again, type your text and press
CTRL+Dto save.) -
Display Line Numbers:
To show line numbers along with the content:cat -n file.txt -
Show Non-Printable Characters:
To visualize non-printable characters (like tabs and newlines):cat -A file.txt
These options make cat a versatile tool for file manipulation in the terminal. If you need more examples or specific use cases, let me know!
