linux中grep基本用法
grep 查詢並且提取檔案內容
常用的匹配模式
hello 包含字元hello
^hello 以字串hello開頭
hello$ 以字串hello結尾
語法格式
grep “條件” 檔名稱
例:
1.在/hello/a.txt檔案中找出包含 hello 的行
grep “hello” /hello/a.txt
hello
11 hello2
2.在/hello/a.txt檔案中找出以 hello開頭的行
grep “^hello” /hello/a.txt
hello
3.在/hello/a.txt檔案中找出以hello結尾的行
# grep “hello$” /hello/a.txt
hello
4.在/hello/a.txt檔案中找出以hello開頭的行,並且寫入到b.txt檔案中
grep “^hello” /hello/a.txt > b.txt
[root@hello hello]# cat b.txt
hello
相關文章
- AIX 中grep 的用法幫助AI
- Linux 常用基本命令 cat grepLinux
- linux下grep命令用法例項教程Linux
- git grep命令用法Git
- linux三劍客(grep、sed、awk)基本使用Linux
- C++中& 的基本用法C++
- Linux系統中grep如何使用?Linux
- linux shell 指令碼之深入淺出的grep的用法Linux指令碼
- aix基本命令之grepAI
- Linux grepLinux
- linux useradd命令的基本用法Linux
- LINUX下RPM命令基本用法Linux
- 掌握Linux中的12個grep命令Linux
- Linux grep 命令Linux
- linux-grepLinux
- 【Linux】grep命令Linux
- getopt_long函式基本用法-linux函式Linux
- Linux之grep中的正規表示式Linux
- linux中sed用法Linux
- linux中#和## 用法Linux
- linux LVM 磁碟管理 基本用法舉例LinuxLVM
- Linux 中 grep 命令的 12 個實踐例子Linux
- linux命令之grepLinux
- 【Linux命令】grep命令Linux
- Linux - find與grepLinux
- Oracle 10g RAC中Srvctl基本用法Oracle 10g
- Promise基本用法Promise
- Git基本用法Git
- mongoose基本用法Go
- tcpdump基本用法TCP
- Linux中wget用法Linuxwget
- grep 命令系列:grep 中的正規表示式
- Linux grep 命令中的正規表示式詳解Linux
- linux 中 grep匹配 區分空格和製表符Linux
- Linux命令篇 - grep 命令Linux
- Linux基礎命令---grepLinux
- Linux grep命令的使用Linux
- linux grep命令詳解Linux