Linux commands (3) Cat
Cat is viewing the contents of a file
?
Command format: Cat file
Common parameter Description:
-N or-nimber the number of rows for all outputs starting from 1.
Example:
cat/etc/passwd
?
-B or-number-nonblank and-n are similar, except that blank lines are not numbered.
Example:
cat/etc/passwd
?
?
-S or-spueeze-blank when you encounter a blank line that has more than two consecutive lines, replace the blank line with one line
?
First go to the home directory, create several files to test, and enter information
#cd ~???????????????? ------Go to the home directory
#touch yy???????????? ------Create a file named yy
#vi yy???????????? ------Edit the file yy, enter 123456789 inside
Press "ESC" key to stop editing, use "shift+:" to pop up the command bar
Input Wq Save
?
There are three major features of cat:
-
#cd ~???????????? ------Go to the home directory
#cat yy???????? ------Open the file you just created yy
You can see, print out the information we entered ourselves
?
- Create a file from the keyboard, you can only create a file, you cannot edit an existing file.
#cd ~???????????? ------Go to the home directory
#cat > Yy1???????? ------Create the file and enter the content abc,def and use CTRL + C to cancel
#cat yy1???????? ------using cat to view the newly created YY1
?
- Merge several files into one file
#cat yy yy1 > Yy2???????? ------Merge and generate a new file
#cat Yy2???????????????? ------View the new file that you just generated