Introduction of the Order
1.1 mv Modify and Move commands
1.1.1 Mobile Command MV
1.1.2 Modify command MV
[[[email protected] ~]# mv oldboy.txt oldgirl.txt
mv:cannot stat ' oldboy.txt ': No such file or Directory
[[email protected] ~]# ls-l
Total of
-rw-------. 1 root root 1161 Jul 18:28 anaconda-ks.cfgdrwxr-xr-x. 2 root root 4096 Jul 18:33 data
-rw-r--r--. 1 root root 21736 Jul 18:28 install.log
-rw-r--r--. 1 root root 58 18:25 install.log.syslog
1.2 rm command Remove use absolute address
1.2.1 Force Delete rm-f
[[email protected] data]# rm-f/root/d Ata/oldgirl.txt
[[email protected] data]# ls-l/root/data/
Total
-rw-r--r--. 1 root root 7 Jul 11 02:13 Alex.txt
-rw-r--r--. 1 root root 01:16 lidao.txt
-rw-r--r--. 1 root root 254 Jul 02:56 oldboy.txt.bak< br>1.2.2 Force Delete directory RM–FR/RF
[email protected] data]# rm-rf/tmp/data/
[[email protected] data]# ls-l/tmp /data
Ls:cannot access/tmp/data:no such file or directory
rm-rf/tmp/data/
rm-fr/tmp/data/
1.3 Creating an environment touch
Touch/root/oldboy.txt/root/alex.txt/root/lidao.txt
1.4 Find File
1.4.1 #find命令
[[email protected] data]# #find in xxx-type F-Name "Oldboy.txt"
[Email protected] data]#
[Email protected] data]# find/root/-type f-name "Oldboy.txt"
/root/oldboy.txt
-type what type of f file (file) to find
d Directory (directory)
-name "What's the name?"
1.4.2 find+ |xargs Coordination
Find the file and give it to |xgars note "|" It means to pass the previous command out to the latter command.
1.4.3 Find all files with a. txt suffix
Oldboy.txt Lidao.txt Alex.txt
[Email protected] data]# find/root/-type f-name ".txt"
/root/oldboy.txt
/root/lidao.txt
/root/alex.txt
/root/data/lidao.txt
/root/data/alex.txt
[[Email protected] data]# # Any character of any character
[[email protected] data]# find/root/-type f-name ". txt"
/root/oldboy.txt
/root/lidao.txt
/ Root/alex.txt
/root/data/lidao.txt
/root/data/alex.txt
[[email protected] data]# find/root/-type F- Name ". txt" |xargs ls-l
-rw-r--r--. 1 root root 0 Jul 03:21/root/alex.txt
-rw-r--r--. 1 root root 7 Jul 11 02:13/root/data/alex.txt
-rw-r--r--. 1 root root 01:16/root/data/lidao.txt
-rw-r--r--. 1 root root 0 Ju L-03:21/root/lidao.txt
-rw-r--r--. 1 root root 0 Jul 03:21/root/oldboy.txt
1.5 write up the previous directory CD command
1) go to the previous level directory CD ..
2) View multiple top-level directory CDs: /.. /.. /.. /.. /.. /.. /
3) Enter the current directory CD
Chapter 2nd the use of the Three Musketeers of Linux
2.1 grep (filter) Three Musketeers old three
Method 1-grep
[[email protected] data]# #grep filter to display what you want or not
[[email protected] data]# grep "Oldboy"/dat A/test.txt
Oldboy
[[email protected] data]# grep-v "Oldboy"/data/test.txt
Test
Liyao
2.2 Head and tail use
1) head display file The first few lines of content default to 10 lines
[[email protected] data]# head-3/data/ett.txt
1
2
3
2) Tail display the last few lines of the file default to 10 rows
[[email protected] data]# tail-11/data/ett.txt
[
] * * * *
+
+
+
3
(
) The joint use of head and tail
[[email protected] data]# head-30/data/ett.txt |tail-11
2.3
(
)
,
,
,
,
,
,
, and the Three Musketeers. SED command
2.4 The Three Musketeers, the boss, awk.
[[email protected] data]# awk '! /oldboy/'/data/test.txt
Test
Liyao
Finally say sed (good at fetching) SED ' 3p '/data/ett.txt default output will add a "3" to the column and you enter Sed–n ' 3p '/data/ett.txt results will only show "3" Sed–n ' 3,5p ' data/ett.txt The result is a number between 3 and 5 rows. Note Here-n is the default row output cancellation.
Awk (good at going to columns) such as awk ' NR ' ==3+ address ' results are shown on line 3rd. awk ' nr ' >3+ address output is larger than the third row of columns awk ' NR ' <3+ address shows rows less than 3 awk ' nr==3,nr==5 ' + address showing 3 to 5 lines.
[Email protected] data]# awk ' nr<2 '/data/ett.txt
1
[Email protected] data]# awk ' nr==10,nr==20 '/data/ett.txt
10
11
12
13
14
15
16
17
18
19
20
Linux commands and the Three Musketeers (grep sed awk)