One, cat1.1, view the contents of the file
Format: Cat file name
cat /etc/10.198. 1.1 8.8. 8.8
However, when the file content is more than one screen, the cat command can not meet the viewing requirements, you need to use the more|less to view
1.2. Redirect the input file contents to the new file
cat /etc/resolv.conf >cat10.198. 1.18.8. 8.8
A ">" means emptying the file, re-writing the new content, emptying if the file exists, creating if the file does not exist
Two ">>" means the end appended at the end of the file, and if the file exists, it will be created if the file does not exist.
[Email protected] documents]#Cat/etc/httpd/conf.d/welcome.conf >>A.txt[[email protected] documents]#Cata.txt # Generated by Networkmanagernameserver10.198.1.1nameserver8.8.8.8# # This configurationfileEnables the default"Welcome"# pageifThere is no default index page present for# The root URL. To disable the Welcome page, comment# out all the lines below.#<locationmatch"^/+$">Options-Indexes errordocument403/error/noindex.html</LocationMatch>[email protected] documents]#
1.3. redirect files to empty or append content
[[email protected] documents]# cat > A.txt<<gg > Hello Linux > gg[[email Protected] documents]# A.txt Hello Linux[[email protected] documents]#
cat >> a.txt <<fw> rrrrrrrrrrrrrr> qqqqqqqqq> Wwwwwwwwwww> eeeeee>cat
The meat between the 2 identifiers is written to the file, 2 identifiers can be customized, and a pair appears
A ">" means emptying the file, re-writing the new content, emptying if the file exists, creating if the file does not exist
Two ">>" means the end appended at the end of the file, and if the file exists, it will be created if the file does not exist.
Second, more/less
Format: more/less file name
Used for file content comparison view file content: With a carriage return or a space to page down, press B to page UP, press the Q key to exit
Cat paging is often used with the more commands, and the Cat command is the ability to combine several files into one file.
More command function: Let the screen display full page when the pause, at this time can press the empty SPACEBAR continue to display the next screen, or press the Q key to stop the display.
Less command function: The less command is similar to the more command and can be used to browse over a page of files. The difference is that the less command, in addition to pressing the SPACEBAR to display the file down, can also use the up and down keys to scroll the file. When you want to end the browsing, simply press the Q key under the ":" Prompt in the less command.
In fact, these three commands, in addition to the cat command has the ability to merge files, the rest of the function is similar, but from the browsing habits and display different ways.
Third, grep
is a powerful text search tool that can use regular expressions to search for text and print matching lines
grep " Q " grep"q"
Iv. VI
Simple command:
Simple application:
VI File name
Press the I key to edit
Press Esc,:q to exit without saving
Press esc,:q! to exit without saving
Press ESC,:WQ to exit save
Basic operation of Linux on file content (Study note seven)