Shell字符串匹配
转意的"尖括号" -- \<...\> -- 用于匹配单词边界.
查看文件内容:
hanbingxin@andLinux:~$ cat 1.txt
1. dfjksdfjklsdj dllthesdj dsjfksldfj
2. sdf the dksfksdf thesdf sdlfjsld
3. the
4. sdkfjklsdfjsdklfjsdklfjksdjfks
用不带"尖括号"进行匹配
hanbingxin@andLinux:~$ grep 'the' 1.txt
1. dfjksdfjklsdj dllthesdj dsjfksldfj
2. sdf the dksfksdf thesdf sdlfjsld
3. the
用带"尖括号"进行匹配
hanbingxin@andLinux:~$ grep '\<the\>' 1.txt
2. sdf the dksfksdf thesdf sdlfjsld
3. the
转意的"尖括号" -- \<...\> -- 用于匹配单词边界.
查看文件内容:
hanbingxin@andLinux:~$ cat 1.txt
1. dfjksdfjklsdj dllthesdj dsjfksldfj
2. sdf the dksfksdf thesdf sdlfjsld
3. the
4. sdkfjklsdfjsdklfjsdklfjksdjfks
用不带"尖括号"进行匹配
hanbingxin@andLinux:~$ grep 'the' 1.txt
1. dfjksdfjklsdj dllthesdj dsjfksldfj
2. sdf the dksfksdf thesdf sdlfjsld
3. the
用带"尖括号"进行匹配
hanbingxin@andLinux:~$ grep '\<the\>' 1.txt
2. sdf the dksfksdf thesdf sdlfjsld
3. the