Linux Learning---Day04

Source: Internet
Author: User

1.find/data/-type f-exec rm-f {} \; Delete all files under directory/data
2.\ let a meaningful character take off the vest
. Current directory
.. Parent Directory
. Representative point number
3.find/data/-type F|xargs rm-f
Delete all files under directory/data
4.| Pipe character, the output of the previous command results to the next program to continue processing
5.find/data-type f! -name "C.txt" |xargs rm-f Delete all files in the directory, but keep only c.txt
6.find/data-name
Find by name
Find./-type f-name "test.txt"-exec sed-i ' s#bcd#abc#g ' {} \; replace the BCD characters in the current directory and all test.txt files in the recursive directory with ABC (this method is serial)
Find./-type f-name "test.txt" |xargs sed-i ' s#abc#cba#g '
Replace the ABC characters in the current directory and all test.txt files in the recursive directory with the CBA (this method is serial processing)
Sed-i ' S#cba#bcd#g ' find ./ -type f -name "test.txt" replace the CBA characters in the current directory and all test.txt files in the recursive directory with BCD (this method is more efficient for parallel processing)
7.! On behalf of "Take the opposite", namely "non" meaning
8.cat >>test.txt<<eof
Test
Liyao
Aa
Eof
9.grep
Filter and print, isolate what you want and don't Want (Linux musketeers, good at filtering)
Sed Stream Editor filter (Linux Three Musketeers, good at fetching rows)
Sed-n '/filtered content/processed commands ' file
-N
Cancel the default output of SED
-I. Change the contents of a file
Processed commands: P print printing, d delete delete
grep "AA" Test.txt
Filter AA from Test.txt
Sed-n '/aa/p ' test.txt Filter AA from Test.txt
Grep-v "AA" Test.txt
Filter from test.txt except AA
Sed '/aa/d ' test.txt filter from test.txt except AA
Sed-i ' s#aaa#bbb#g ' test.txt
Replace AAA with Bbbbr/>*s often said find and replace, with one string replaced by another
When *g (global) is used in conjunction with S, it represents the replacement of the current row global match
* Here the "#" is the delimiter, can be replaced with/,@,=, etc.
In addition to displaying a matching row, and displaying the n rows before the row
Grep-aIn addition to displaying a matching row, and displaying the n rows after the row
Grep-c in addition to displaying a matching row, and displaying the rows of n rows before and after
grep "string"-B test.txt
Sed-n ' 20,30p ' test.txt
View the contents of line 20th to 30th in the Test.txt file (easy-to-use and efficient method)
Awk a language that can filter content (Fetch columns), print content, delete content (Linux musketeers, good at fetching columns)
awk ' {print $} ' file
The first column, the second column, $NF the last column, $ (NF-1) the penultimate column
Awk-f ":" ' {print $} '/etc/passwd Print first column,-F custom delimiter
Awk-f ":" ' {print $ '-"$"-"$ $} '/etc/passwd
Print first column-second column-third column
awk ' {if (nr<31 && nr>19) print ' \ n '} ' test.txt Print the contents of line 20th to 30th in the Test.txt file (NR stands for line number,&& and \ n returns to newline)
10.ctrl+c
Force interrupt execution of the program, terminate the process
CTRL + Z</em> Suspends the current program and suspends execution of the program. With the BG and FG commands to switch between the front and rear stations, the FG command restarts the interrupted task in the foreground, and the BG command places the interrupted task in the background execution.
Ctrl+d
Instead of sending a signal, it represents a special binary value that represents EOF; in the shell, Ctrl-d represents the launch of the current shell, such as when you return from admin root to your normal user.
11.head fetch n rows at the beginning of the file, the default is the first 10 rows
Head-n 3
Take the first three lines
Head-3 take the first three lines
Tail
Take the n rows at the end of the file, and the default is 10 lines at the end
Tail-n 3 Take the end propelled
Tail-3
Take the end propelled
Tail-f Test.txt track real-time changes in a file's trailer
head-30 test.txt |tail-11
View the contents of line 20th to 30th in the Test.txt file
12.mkdir-p/ROOT/DATA/AA - p stands for recursive creation of directories
13.yum
Linux Package Manager (download package and then call RPM command install package)
Yum Install Tree-y Download Install tree
RPM-IVH (-i install,-v display output,-H to human readable display)
RPM-IVH package name. RPM (pre-download good)
The biggest problem, the dependency problem is not solved, Yum helps to solve the dependency problem
Rpm-qa Tree Query Tree This package (-Q query,-a All)
14.tree
Show directory tree structure
15./bin/cp/mnt/test.txt/tmp/
\cp/mnt/test.txt/tmp/
cp = ' Cp-i '
16.alias View and define aliases
Aa= ' echo ' I am AA Linux. "'
Alias rm= ' echo ' RM can not is USED,PLS use MV "'
To modify aliases: VI ~/.BASHRC
Valid for all users: VI/ETC/BASHRC or/etc/profile
Entry into force: SOURCE/ETC/BASHRC or/etc/profile
Unalias
Remove alias pwd
17.seq sequence Sequence
seq [OPTION] ... Last
seq [OPTION] ... First Last
seq [OPTION] ... First INCREMENT Last
Seq-s "Custom delimiter"
-S self-setting a separator for landscape display

Linux Learning---Day04

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.