马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有账号?立即注册
×
目次
1. ls 指令
2. pwd下令
3. cd 指令
4. touch 指令
5. mkdir指令
6. rmdir指令&&rm指令
7. rm下令可以同时删除文件或目次
8. man指令
9. cp指令
10. mv指令
11. cat 指令
12. more指令
13. less 指令
14. head指令
15. tail 指令
16. find 指令
17. which指令
18. whereis 指令
19. alias 指令
20. grep 指令
1. ls 指令
语法: ls [ 选项 ] [ 文件 ]
对于目次,该下令列出该目次下的全部子目次与文件。对于文件,将列出⽂件名以及其他信息。
常用选项:
-a 列出⽬录下的全部文件,包罗以.开头的隐含⽂件。
-d 将⽬录像⽂件⼀样表现,而不是表现其下的⽂件。如:ls ‒d 指定目次
-i 输出⽂件的i节点的索引信息。如 ls ‒ ai 指定文件
-k 以k字节的情势表现文件的巨细。如 ls ‒ alk 指定文件
-l 列出文件的详细信息
-r 对目次反向排序
-t 以时间排序
举例:
- [iu@iZ2ze5ncfh4b12o80084czZ study]$ ls lesson2
- dir pd1 test.c test.zip
- [iu@iZ2ze5ncfh4b12o80084czZ lesson2]$ ls -a
- . .. dir pd1 test.c test.zip
- [iu@iZ2ze5ncfh4b12o80084czZ lesson2]$ ls -a -l
- total 24
- drwxr-xr-x 4 root root 4096 Feb 23 18:13 .
- drwxr-xrwx 8 root root 4096 Feb 26 22:03 ..
- drwxr-xr-x 2 root root 4096 Feb 23 18:13 dir
- drwxr-xr-x 3 root root 4096 Feb 23 18:13 pd1
- -rw-r--r-- 1 root root 72 Feb 23 18:13 test.c
- -rw-r--r-- 1 root root 193 Feb 23 18:13 test.zip
- [iu@iZ2ze5ncfh4b12o80084czZ lesson2]$ ls -a -l -f
- .. dir . test.zip test.c pd1
- [iu@iZ2ze5ncfh4b12o80084czZ lesson2]$ ls -a -l -F
- total 24
- drwxr-xr-x 4 root root 4096 Feb 23 18:13 ./
- drwxr-xrwx 8 root root 4096 Feb 26 22:03 ../
- drwxr-xr-x 2 root root 4096 Feb 23 18:13 dir/
- drwxr-xr-x 3 root root 4096 Feb 23 18:13 pd1/
- -rw-r--r-- 1 root root 72 Feb 23 18:13 test.c
- -rw-r--r-- 1 root root 193 Feb 23 18:13 test.zip
- [iu@iZ2ze5ncfh4b12o80084czZ lesson2]$ ls -a -l -F -n
- total 24
- drwxr-xr-x 4 0 0 4096 Feb 23 18:13 ./
- drwxr-xrwx 8 0 0 4096 Feb 26 22:03 ../
- drwxr-xr-x 2 0 0 4096 Feb 23 18:13 dir/
- drwxr-xr-x 3 0 0 4096 Feb 23 18:13 pd1/
- -rw-r--r-- 1 0 0 72 Feb 23 18:13 test.c
- -rw-r--r-- 1 0 0 193 Feb 23 18:13 test.zip
复制代码 2. pwd下令
语法:pwd
表现⽤户当前地点的目次。
- [iu@iZ2ze5ncfh4b12o80084czZ study]$ pwd
- /home/iu/study
复制代码 3. cd 指令
Linux体系中,磁盘上的文件和目次被构成⼀棵目次树,每个节点都是目次或文件,此中寻常⽂件⼀定是目次树的叶子节点。
明白路径存在的意义:树状构造方式,都是为了包管快速定位查找到指定的文件,而定位⽂件就必要具有唯⼀性的方案来举行定位⽂件。此中任何⼀个节点,都只有⼀个父节点,以是,从根目次开始,定位指定文件,路径具有唯⼀性。
路径:
绝对路径:⼀般从/开始,不依赖其他目次的定位⽂件的方式
相对路径:相对于当前用户所处目次,定位⽂件的路径方式
绝对路径⼀般不会随着用户的路径变革而丧失唯⼀性,⼀般在特定服务的设置文件中经常被利用;相对路径由于它的便捷性,⼀般在下令行中利用较多
- [iu@iZ2ze5ncfh4b12o80084czZ study]$ cd /home/iu/study[iu@iZ2ze5ncfh4b12o80084czZ study]$ pwd
- /home/iu/study// .. 可以返回上级目次[iu@iZ2ze5ncfh4b12o80084czZ study]$ cd ..[iu@iZ2ze5ncfh4b12o80084czZ ~]$ pwd/home/iu[iu@iZ2ze5ncfh4b12o80084czZ ~]$ cd /home/iu/study/lesson1[iu@iZ2ze5ncfh4b12o80084czZ lesson1]$ pwd/home/iu/study/lesson1[iu@iZ2ze5ncfh4b12o80084czZ lesson1]$ cd ../lesson2[iu@iZ2ze5ncfh4b12o80084czZ lesson2]$ pwd/home/iu/study/lesson2// - 直接回退到近来一次所处的目次[iu@iZ2ze5ncfh4b12o80084czZ lesson2]$ cd -/home/iu/study/lesson1// ~ 返回抵家目次[iu@iZ2ze5ncfh4b12o80084czZ lesson1]$ cd ~[iu@iZ2ze5ncfh4b12o80084czZ ~]$ pwd/home/iu
复制代码 4. touch 指令
语法: touch [选项]... [文件] ...
touch下令参数可更改文档或目次的日期时间,包罗存取时间和更改时间,大概新建⼀个不存在的文件。
常用选项:
-a: change only the access time
-c: change only the modification time
举例:
- //创建普通⽂件
- [iu@iZ2ze5ncfh4b12o80084czZ test]$ ls
- dir file.txt
- [iu@iZ2ze5ncfh4b12o80084czZ test]$ touch newFile.txt
- [iu@iZ2ze5ncfh4b12o80084czZ test]$ ls
- dir file.txt newFile.txt
- //修改⽂件access时间
- [iu@iZ2ze5ncfh4b12o80084czZ test]$ touch -a newFile.txt
- //修改⽂件Modify时间
- [iu@iZ2ze5ncfh4b12o80084czZ test]$ touch -m newFile.txt
复制代码 5. mkdir指令
语法: mkdir [选项] [文件]...
在当前目次下创建⼀个名为“dirname”的目次
常用选项:
-p: 可以是⼀个路径名称。此时若路径中的某些目次尚不存在,加上此选项后,体系将自动创建好那些尚不存在的目次,即⼀次可以创建多个目次。
- //创建普通空⽬录
- [iu@iZ2ze5ncfh4b12o80084czZ test]$ ls -l
- total 4
- drwxrwxr-x 2 iu iu 4096 Jan 11 14:22 dir
- -rw-rw-r-- 1 iu iu 0 Jan 11 14:22 file.txt
- -rw-rw-r-- 1 iu iu 0 Jan 11 15:09 newFile.txt
- [iu@iZ2ze5ncfh4b12o80084czZ test]$ mkdir mydir
- [iu@iZ2ze5ncfh4b12o80084czZ test]$ ls -l
- total 8
- drwxrwxr-x 2 iu iu 4096 Jan 11 14:22 dir
- -rw-rw-r-- 1 iu iu 0 Jan 11 14:22 file.txt
- drwxrwxr-x 2 iu iu 4096 Jan 11 15:15 mydir
- -rw-rw-r-- 1 iu iu 0 Jan 11 15:09 newFile.txt
- //递归建⽴多个⽬录,创建指定路径
- [iu@iZ2ze5ncfh4b12o80084czZ test]$ mkdir -p path1/path2/path3/path4
- [iu@iZ2ze5ncfh4b12o80084czZ test]$ ls -l
- total 12
- drwxrwxr-x 2 iu iu 4096 Jan 11 14:22 dir
- -rw-rw-r-- 1 iu iu 0 Jan 11 14:22 file.txt
- drwxrwxr-x 2 iu iu 4096 Jan 11 15:15 mydir
- -rw-rw-r-- 1 iu iu 0 Jan 11 15:09 newFile.txt
- drwxrwxr-x 3 iu iu 4096 Jan 11 15:16 path1
- [whb@bite-alicloud test]$ tree path1
- path1
- └── path2
- └── path3
- └── path4
复制代码 6. rmdir指令
rmdir是⼀个与mkdir相对应的下令,mkdir是创建目次,而rmdir是删除下令
语法:rmdir [参数] [文件]
删除空目次
实用对象:具有当前目次利用权限的全部利用者
常用选项:
-p 当子目次被删除后假如父目次也酿成空目次的话,就连带父目次⼀起删除。
举例:
- //删除空⽬录
- [iu@iZ2ze5ncfh4b12o80084czZ test]$ ll
- total 12
- drwxrwxr-x 2 iu iu 4096 Jan 11 14:22 dir
- -rw-rw-r-- 1 iu iu 0 Jan 11 14:22 file.txt
- drwxrwxr-x 2 iu iu 4096 Jan 11 15:15 mydir
- -rw-rw-r-- 1 iu iu 0 Jan 11 15:09 newFile.txt
- drwxrwxr-x 3 iu iu 4096 Jan 11 15:16 path1
- [iu@iZ2ze5ncfh4b12o80084czZ test]$ tree mydir/
- mydir/
- 0 directories, 0 files
- [wiu@iZ2ze5ncfh4b12o80084czZ test]$ rmdir mydir
- [iu@iZ2ze5ncfh4b12o80084czZ test]$ ll
- total 8
- drwxrwxr-x 2 iu iu 4096 Jan 11 14:22 dir
- -rw-rw-r-- 1 iu iu 0 Jan 11 14:22 file.txt
- -rw-rw-r-- 1 iu iu 0 Jan 11 15:09 newFile.txt
- drwxrwxr-x 3 iu iu 4096 Jan 11 15:16 path1
-
- //删除路径
- [iu@iZ2ze5ncfh4b12o80084czZ test]$ tree path1
- path1
- └── path2
- └── path3
- └── path4
- 3 directories, 0 files
- [iu@iZ2ze5ncfh4b12o80084czZ test]$ rmdir -p path1/path2/path3/path4
- [iu@iZ2ze5ncfh4b12o80084czZ test]$ ll
- total 4
- drwxrwxr-x 2 iu iu 4096 Jan 11 14:22 dir
- -rw-rw-r-- 1 iu iu 0 Jan 11 14:22 file.txt
- -rw-rw-r-- 1 iu iu 0 Jan 11 15:09 newFile.txt
- //指定路径中有不为空的路径,便⽆法删除
- [iu@iZ2ze5ncfh4b12o80084czZ test]$ rmdir -p path1/path2/path3
- rmdir: failed to remove ‘path1/path2/path3’: Directory not empty
- [iu@iZ2ze5ncfh4b12o80084czZ test]$ touch path1/myfile.txt
- [iu@iZ2ze5ncfh4b12o80084czZ test]$ touch path1/path2/myfile.txt
- [iu@iZ2ze5ncfh4b12o80084czZ test]$ tree path1/
- path1/
- ├── myfile.txt
- └── path2
- ├── myfile.txt
- └── path3
- └── path4
- 3 directories, 2 files
- [iu@iZ2ze5ncfh4b12o80084czZ test]$ rmdir -p path1/path2/path3/path4
- rmdir: failed to remove directory ‘path1/path2’: Directory not empt
复制代码 7. rm下令
语法: rm [参数] [文件]
删除文件或目次
适⽤对象:全部利用者
常用选项:
-f 纵然文件属性为只读,直接删除
-i 删除前逐⼀扣问确认
-r 删除⽬录及其下全部文件
举例:
- //删除普通⽂件
- [iu@iZ2ze5ncfh4b12o80084czZ test]$ ll
- total 8
- drwxrwxr-x 2 iu iu 4096 Jan 11 14:22 dir
- -rw-rw-r-- 1 iu iu 0 Jan 11 14:22 file.txt
- -rw-rw-r-- 1 iu iu 0 Jan 11 15:09 newFile.txt
- drwxrwxr-x 3 iu iu 4096 Jan 11 15:26 path1
- [iu@iZ2ze5ncfh4b12o80084czZ test]$ rm file.txt
- [iu@iZ2ze5ncfh4b12o80084czZ test]$ ll
- total 8
- drwxrwxr-x 2 iu iu 4096 Jan 11 14:22 dir
- -rw-rw-r-- 1 iu iu 0 Jan 11 15:09 newFile.txt
- drwxrwxr-x 3 iu iu 4096 Jan 11 15:26 path1
- //删除⽬录⽂件
- [iu@iZ2ze5ncfh4b12o80084czZ test]$ ll
- total 8
- drwxrwxr-x 2 iu iu 4096 Jan 11 14:22 dir
- -rw-rw-r-- 1 iu iu 0 Jan 11 15:09 newFile.txt
- drwxrwxr-x 3 iu iu 4096 Jan 11 15:26 path1
- [iu@iZ2ze5ncfh4b12o80084czZ test]$ rm dir
- rm: cannot remove ‘dir’: Is a directory
- [iu@iZ2ze5ncfh4b12o80084czZ test]$ rm -r dir
- [iu@iZ2ze5ncfh4b12o80084czZ test]$ ll
- total 4
- -rw-rw-r-- 1 iu iu 0 Jan 11 15:09 newFile.txt
- drwxrwxr-x 3 iu iu 4096 Jan 11 15:26 path1
复制代码 8. man指令
语法:man [ 选项 ] 下令
查察联机手册获取资助
常用选项:
-k 根据关键字搜刮联机资助
num 只在第num章节查找
-a 将全部章节的都显⽰出来,⽐如man printf它缺省从第⼀章开始搜刮,知道就制止,用a选 项,当按下q退出,他会继承今后⾯搜刮,直到全部章节都搜刮完毕
举例:
- [iu@iZ2ze5ncfh4b12o80084czZ test]$ man printf
- [iu@iZ2ze5ncfh4b12o80084czZ test]$ man fork
- [iu@iZ2ze5ncfh4b12o80084czZ test]$ man 2 frok
- [iu@iZ2ze5ncfh4b12o80084czZ test]$ man 3 printf
- [iu@iZ2ze5ncfh4b12o80084czZ test]$ man 7 signal
- [iu@iZ2ze5ncfh4b12o80084czZ test]$ man man
复制代码 9. cp指令
语法: cp [ 选项 ] 源文件或目次 目的文件或目次
复制文件或目次(cp指令用于复制文件或目次,如同时指定两个以上的文件或目次,且末了的目的地是⼀个已经存在的目次,则它会把前面指定的全部文件或目次复制到此目次中)
常用选项:
-f或--force 强⾏复制文件或目次,岂论目的⽂件或目次是否已经存在
-i或--interactive 覆盖文件先扣问用户
-r 递归处理处罚,将指定目次下的文件与子目次⼀并处理处罚。
举例:
- //cp普通⽂件
- [iu@iZ2ze5ncfh4b12o80084czZ test]$ echo "hello ">myfile.txt
- [iu@iZ2ze5ncfh4b12o80084czZ test]$ cat myfile.txt
- hello
- [iu@iZ2ze5ncfh4b12o80084czZ test]$ ll
- total 4-rw-rw-r-- 1 iu iu 22 Jan 11 15:47 myfile.txt
- [iu@iZ2ze5ncfh4b12o80084czZ test]$ cp myfile.txt myfile-backup.txt
- [iu@iZ2ze5ncfh4b12o80084czZ test]$ ll
- total 8
- -rw-rw-r-- 1 iu iu 22 Jan 11 15:47 myfile-backup.txt
- -rw-rw-r-- 1 iu iu 22 Jan 11 15:47 myfile.txt
- [iu@iZ2ze5ncfh4b12o80084czZ test]$ cat myfile-backup.txt
- hello
- //cp如果⽬标⽂件存在,就覆盖
- [iu@iZ2ze5ncfh4b12o80084czZ test]$ echo "hello iu" > myfile.txt
- [iu@iZ2ze5ncfh4b12o80084czZ test]$ cat myfile.txt
- hello iu
- [iu@iZ2ze5ncfh4b12o80084czZ test]$ cp myfile.txt myfile-backup.txt
- [iu@iZ2ze5ncfh4b12o80084czZ test]$ cat myfile-backup.txt
- hello iu
复制代码 10. mv指令
语法: mv [选项] 源文件或目次 目的文件或目次
mv下令是move的缩写,可以用来移动文件大概将文件改名,经常用备份文件大概目次
a)mv下令中第⼆个参数范例的差异(是文件还是目次),mv下令将文件重定名或将其移至⼀个新的目次中。
b)当第⼆个参数范例是文件时,mv下令完成文件重定名,此时,源文件只能有⼀个,它将所给的源文件或目次重定名为给定的目的⽂件名。
c)当第⼆个参数是已存在的目次名称时,目次参数可以有多个,mv下令将各参数指定的源文件都移至目的目次中。
常用选项:
-f:force欺压的意思,假如目的文件已经存在,不会扣问而直接覆盖
-i:若目的文件已经存在时,就会扣问是否覆盖。
举例:
- //更改名称
- [iu@iZ2ze5ncfh4b12o80084czZ test]$ touch myfile.txt
- [iu@iZ2ze5ncfh4b12o80084czZ test]$ ll
- total 0-rw-rw-r-- 1 iu iu 0 Jan 11 15:56 myfile.txt
- [iu@iZ2ze5ncfh4b12o80084czZ test]$ mv myfile.txt yourfile.txt
- [iu@iZ2ze5ncfh4b12o80084czZ test]$ ll
- total 0
- -rw-rw-r-- 1 iu iu 0 Jan 11 15:56 yourfile.txt
- //如果当前路径存在同名⽂件,改名即覆盖
- [iu@iZ2ze5ncfh4b12o80084czZ test]$ touch myfile.txt
- [iu@iZ2ze5ncfh4b12o80084czZ test]$ ll
- total 0
- -rw-rw-r-- 1 iu iu 0 Jan 11 15:58 myfile.txt
- -rw-rw-r-- 1 iu iu 0 Jan 11 15:57 yourfile.txt
- [iu@iZ2ze5ncfh4b12o80084czZ test]$ mv yourfile.txt myfile.txt
- [iu@iZ2ze5ncfh4b12o80084czZ test]$ ll
- total 0
- -rw-rw-r-- 1 iu iu 0 Jan 11 15:57 myfile.txt
复制代码 11. cat 指令
语法: cat [ 选项 ] [ 文件 ]
查察目的文件的内容
常用选项:
-b 对非空输出行编号
-n 对输出的全部行编号
-s 不输出多行空行
举例:
- [whb@bite-alicloud test]$ cnt=0; while [ $cnt -le 20 ]; do echo "hello iu";
- let cnt++; done > temp.txt
- [whb@bite-alicloud test]$ cat -b temp.txt
- 1 hello iu
- 2 hello iu
- 3 hello iu
- 4 hello iu
- 5 hello iu
- 6 hello iu
- 7 hello iu
- 8 hello iu
- 9 hello iu
- 10 hello iu
- ...
复制代码 12. more指令
语法: more [选项]
more下令,功能雷同cat,但是可以通过下键,向下查找,但不能向上查找
常用选项:
-n 指定输出行数
q 退出more
举例:
- [iu@iZ2ze5ncfh4b12o80084czZ test]$ cnt=0; while [ $cnt -le 2000 ]; do echo "hello
- iu"; let cnt++; done > temp.txt
- //-n指定输出⾏数
- [iu@iZ2ze5ncfh4b12o80084czZ test]$ more -10 temp.txt
- hello iu
- hello iu
- hello iu
- hello iu
- hello iu
- hello iu
- hello iu
- hello iu
- hello iu
- hello iu
- --More--(0%)
复制代码 13. less 指令
语法: less [ 参数 ] 文件
less与more雷同,但利用less可以随意欣赏文件,而more仅能向前移动,却不能向后移动,而且less在查察之前不会加载全部文件。
常用选项:
-i 忽略搜刮时的巨细写
-N 表现每行的行号
/字符串:向下搜刮“字符串”的功能
?字符串:向上搜刮“字符串”的功能
q 退出
举例:
- //命令⾏输出多⾏⽂本
- [iu@iZ2ze5ncfh4b12o80084czZ test]$ cnt=0; while [ $cnt -le 2000 ]; do echo "hello
- $cnt"; let cnt++; done > temp.txt
- // 测试搜索和-N等功能
- [iu@iZ2ze5ncfh4b12o80084czZ test]$ less -N temp.txt
- 1 hello 0
- 2 hello 1
- 3 hello 2
- 4 hello 3
- 5 hello 4
- 6 hello 5
- 7 hello 6
- 8 hello 7
- 9 hello 8
- 10 hello 9
- 11 hello 10
- 12 hello 11
- 13 hello 12
- 14 hello 13
- ...
复制代码 14. head指令
语法: head[参数] [文件]
head用来表现文件的开头至标准输出中(默认head下令打印其文件的开头10行)。
常用选项:
-n <行数> 表现的行数
举例:
- [iu@iZ2ze5ncfh4b12o80084czZ test]$ head temp.txt
- hello 0
- hello 1
- hello 2
- hello 3
- hello 4
- hello 5
- hello 6
- hello 7
- hello 8
- hello 9
- [iu@iZ2ze5ncfh4b12o80084czZ test]$ head -5 temp.txt
- hello 0
- hello 1
- hello 2
- hello 3
- hello 4
复制代码 15. tail 指令
语法: tail [参数] [文件]
用于表现指定文件末了内容,作为输入信息举行处理处罚
常用选项:
-f 循环读取
-n 表现行数
举例:
- [iu@iZ2ze5ncfh4b12o80084czZ test]$ tail temp.txt
- hello 1991
- hello 1992
- hello 1993
- hello 1994
- hello 1995
- hello 1996
- hello 1997
- hello 1998
- hello 1999
- hello 2000
- [iu@iZ2ze5ncfh4b12o80084czZ test]$ tail -3 temp.txt
- hello 1998
- hello 1999
- hello 2000
复制代码 16. find 指令
语法: find [选项] [文件]
⽤于在文件树中查找文件,并作出相应的处理处罚
常用选项:
-name 按照文件名查找文件
举例:
- //在指定路径下搜索执⾏名称的⽂件
-
- [iu@iZ2ze5ncfh4b12o80084czZ test]$ find ~ -name test.c
- /home/iu/test_code/code/test.c
- /home/iu/test_code/test.c
复制代码 17. which指令
语法: which [体系下令文件]
搜刮体系指定的下令
举例:
- [iu@iZ2ze5ncfh4b12o80084czZ test]$ which ls
- alias ls='ls --color=auto'
- /usr/bin/ls
- [iu@iZ2ze5ncfh4b12o80084czZ test]$ which pwd
- /usr/bin/pwd
复制代码 18. whereis 指令
语法: whereis [文件]
用于找到步伐的源、⼆进制文件或手册
举例:
- [iu@iZ2ze5ncfh4b12o80084czZ test]$ whereis ls
- ls: /usr/bin/ls /usr/share/man/man1/ls.1.gz /usr/share/man/man1p/ls.1p.gz
- [iu@iZ2ze5ncfh4b12o80084czZ test]$ whereis libc.so
- libc: /usr/lib64/libc.so /usr/lib64/libc.a /usr/share/man/man7/libc.7.gz
复制代码 19. alias 指令
语法:alias [文件]=“name”
设置下令的别名
举例:
- [iu@iZ2ze5ncfh4b12o80084czZ test]$ alias iu='ls -a -l -n'
- [iu@iZ2ze5ncfh4b12o80084czZ test]$ which iu
- alias iu='ls -a -l -n'
- /usr/bin/ls
- [iu@iZ2ze5ncfh4b12o80084czZ test]$ iu
- total 36
- drwxrwxr-x 2 1000 1003 4096 Jan 11 17:59 .
- drwx------ 22 1003 1003 4096 Jan 11 17:57 ..
- -rw-rw-r-- 1 1003 1003 28667 Jan 11 18:29 temp.txt
复制代码 20. grep 指令
语法: grep [选项] 征采字符串 文件
在⽂件中搜刮字符串,将找到的行并打印出来
常用选项:
-i: 忽略巨细写,巨细写视为雷同
-n:输出行号
-v:反向选择,亦即表现出没有'征采字符串'内容的那一行
举例:
- [iu@iZ2ze5ncfh4b12o80084czZ test]$ cat temp.txt
- abcd
- ABCD
- hello
- iu
- 1234
- //基本查找
- [iu@iZ2ze5ncfh4b12o80084czZ test]$ grep "abcd" temp.txt
- abcd
- //忽略⼤⼩写的不同,所以⼤⼩写视为相同
- [iu@iZ2ze5ncfh4b12o80084czZ test]$ grep -i "abcd" temp.txt
- abcd
- ABCD
- //输出⾏号
-
- [iu@iZ2ze5ncfh4b12o80084czZ test]$ grep -n "abcd" temp.txt
- 1:abcd
- [iu@iZ2ze5ncfh4b12o80084czZ test]$ grep -ni "abcd" temp.txt
- 1:abcd
- 2:ABCD
- //反向选择,亦即显⽰出没有搜寻字符串内容的那⼀⾏
- [iu@iZ2ze5ncfh4b12o80084czZ test]$ grep -v "abcd" temp.txt
- ABCD
- hello
- iu
- 1234
- [iu@iZ2ze5ncfh4b12o80084czZ test]$ grep -vn "abcd" temp.txt
- 2:ABCD
- 3:hello
- 4:iu
- 5:1234
- [iu@iZ2ze5ncfh4b12o80084czZ test]$ grep -vni "abcd" temp.txt
- 3:hello
- 4:iu
- 5:1234
复制代码 免责声明:如果侵犯了您的权益,请联系站长,我们会及时删除侵权内容,谢谢合作!更多信息从访问主页:qidao123.com:ToB企服之家,中国第一个企服评测及商务社交产业平台。
|