You can get the advice from IT HELP DESK
This time I will explain the command to check the contents of Linux file ~
#cat [option] [filename1] [filename2] ...
The cat command is the most basic command to output a file. You can use it as well as copy and print files. You can also output multiple files at once.
Note that if the file is a text file, the contents will be output normally. However, if it is a binary file, the output will not be recognized.
The major options are:
|-b||Blank without a line number.|
|-n||It gives line numbers including spaces.|
|-E||Displays the newline character as $.|
|-T||Tabs are marked with ^ |.|
|-v||Displays nonprinting characters except newline and tab.|
|-A||Displays all nonprinting characters including newlines and tabs.|
(Option to overlap E, T, v)
|-s||It treats consecutive spaces as a single space.|
1.1 Creating a file
#cat > [filename]
Creates file contents after command input. Save as [Ctrl + d].
1.2 File output
# cat [filename]
If you want to output multiple files at once, use cat [file name1] [file name2] ... [file name n] . Multiple files are output without any distinction.
1.3 Copying Files
#cat [filename1] > [filename2]
You can use the same method as copying the file by transferring the same contents, or you can use it as a method to merge several files.
Below is an example of merging multiple files.
Additionally, store the results of the command to a file you how to. You can use the pipe symbol (|) to create a file. Alternatively, you can use a ">" symbol to make it simpler.
ls -al | cat file1ls -al > file1
Please use the example below to save the required results ~
#more [option] [filename]
more, unlike cat, you can view the contents of a file by page break. It is mainly used for checking longer contents. Used in conjunction with pipe (|) when the output is broken by reading long files.
You can open and edit the file in vi directly from that page, which verifies the contents of a specific file, and you can check the contents of the text file one page at a time.
The options when using the more command are as follows.
|-p||When you move the page, it prints without refreshing the screen without printing it down.|
|-number||Determines how many lines of a page are set.|
|-s||If there are multiple lines of space, it will be shortened to a single space.|
|-d||At the end of a page, [press space to continue, q to quit] appears next to the -more-|
2.1 Commands available during execution
The more command shows the contents of the file on one page, as shown in the above picture.
There are several commands available at this time.
|space||Go to next page|
|enter||Move in line|
|Number + z||Move to next by number line|
|q / Q||more command termination|
|f||Go to next page|
|b||Go to the previous page|
|=||Show current line number|
|v||Run as vi editor|
|/ String||Search for a string. You can use n to find the strings in turn.|
more can be used with the cat command. When using cat command, % of the current page is not displayed as shown in the picture below.
#cat [filename] | more
#less [option] [filename]
more can be read while moving from top to bottom, but less can be moved from top to bottom and from top to bottom. You can also check the contents of a file once it has passed. Also, the speed is very fast because only the contents shown at a time are read out. When reading a large file, you can check the file at a high speed.
3.1 Commands Available During Execution
|space / f||Go to next page|
|b||Go back to previous screen|
|enter||Move one row at a time|
|Number + n||Move as many pages as you like|
|q||Less command termination|
|/ Expression||Search for a string that matches an expression|
|• Expression||Search for previously found strings|
|G||Move to the end of the text file|
As mentioned above, less does not read all the files but prints only the output part, so it does not eat up the memory much and is much faster. You can also check previous documents, which is a common command for many people!
🔔 TIP. Let me summarize the previous contents briefly! 🔔
💡 cat: To print a short document simply cat
💡 more: If you want to see long output results
💡 less: If you want to check a long document a bit more precisely,