Linux study notes - file command

1.3. File commands

1.3.1. Touch
creates an empty file
and can create multiple files at the same time
touch filename1 filename2
If the file name contains spaces, quotation marks are required.
Touch "program files"
is not recommended in Linux

. 1.3.2. cat
displays files content
-n show line number

[root@localhost cn]# cat -n yum.log
     1 contents1
     2  content2
     3  content3

 

Display the command tac backwards

[root@localhost cn]# tac yum.log
content3
content2
content1

 


1.3.3. The more
paging displays the file content. For the
more filename with large file content, the
carriage return will scroll line by line to display the
space or f page by page to turn the page backward
Q or q to exit



1.3.4. Less
is similar to the more command, and it can page up. You can also search
Pageup Page up
Pagedown Page down
Up Arrow Up a line
Down Arrow Down a line

Search
Enter a slash/
then what you can search for, then press enter
n next to find the next one.

1.3.5. head
looks at the first few lines of a file and
looks at the first 10 lines of the file
Head -n 10 filename
-n is optional , the default is the first 10 lines
Head filename
1.3.6. tail
looks at the last few lines of a file
Tail filename
defaults to the last 10 lines. Similar to the following command
Tail -n 10 filename

-f Dynamically display the content at the end of a file
Display the 10 lines at the end of the file, if the content of the file changes, it will automatically refresh the changed content
Tail -f filename

Dynamically display the 20 lines at the end of the file
Tail -20f filename

 

 

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326008971&siteId=291194637