鳥哥私房菜基礎篇筆記04

2021-06-03 15:34:02 字數 1802 閱讀 3988

[root@linux ~] grep 『root』 /var/log/secure

將這個檔案中有root的那一行顯示出來

[root@linux ~] grep –v 『root』 /var/log/secure

將這個檔案中沒有root的那一行顯示出來

[root@linux ~] grep –v 『the 『 test.txt

帶有the的行,及其行號一起顯示出來

[root@linux ~] grep –i 『the 『 test.txt

忽略大小寫

[root@linux ~] grep –n『[g^]oo』 test.txt

將檔案中不是goo開頭的那一行連同行號顯示出來,但必須有oo,可以是foo,too但不是goo

`             [root@linux ~] grep –n『[a-z^]oo』 test.txt

不是小寫英文本母+00字和的那一行

[root@linux ~] grep –n『[0-9]』 test.txt

有數字的那一行

[root@linux ~] grep –n『^the』 test.txt

單詞the只出現在行首

[root@linux ~] grep –n『^[a-z]』 test.txt

字母開頭的行列出來

[root@linux ~] grep –n『^[^a-za-z]』 test.txt

不是英文本母開頭的

^外表示行首,[^]內表示反向選擇

[root@linux ~] grep –n 『\.$』 test.txt

表示以」.」結尾,由於」.」有特殊含義,所以用」\.」轉義

[root@linux ~] grep –n 『^$』 test.txt

將文字中的空行顯示出來

[root@linux ~] grep –v 『^$』 test.txt | grep –v 『^#』

=[root@linux ~] egrep –v 『^$|^#』 test.txt

不是空行和不是以#開頭的行,即去注釋和空行

0*表示擁有空字元或1個0以上的0

00*第乙個0肯定是要存在的第二個0是可有可無的

[root@linux ~] grep –n 『ooo*』 test.txt

文字中至少有2個連續的o列出來

[root@linux ~] grep –n 『goo*g』 test.txt

文字中有至少乙個o的行列出來

.*代表具有0個或至少乙個字元

[root@linux ~] grep –n 『g.*g』 test.txt

以g開頭和結束的字元

[root@linux ~] grep –n 『[0-9] [0-9]*』 test.txt

具有數字的行

限定字元數

[root@linux ~] grep –n 『0\』 test.txt

\為轉義符號,對{}轉義,表示文字中有2個0的行

[root@linux ~] grep –n 『go\g』 test.txt

g後面接2-5個o,然後再接乙個g的行

比較2個檔案的差別

[root@linux ~] diff first.txt second.txt 用於文字檔案

[root@linux ~] cmp first.txt second.txt 用於二進位制檔案

鳥哥私房菜基礎篇筆記03

1,vim 0 移動到這一行的最前面字元處 移動到這一行最後面的字元 yy複製游標所在的那一行,u,復員前乙個操作,ctrl r 重複上乙個操作 2,shell alias lm ls al 別名設定 unalias lm 取消別名設定 3,環境變數 root linux myname dongru...

鳥哥私房菜 基礎篇(4)

關於執行檔案路徑變數 path 為什麼我們可以在任何地方執行 bin ls 這個變數呢?為什麼說我們可以在任何目錄下直接輸入ls就可以執行 bin ls呢?答案就是有執行檔案路徑變數 新增目錄至檔案路徑變數path 語法 path path 路徑名 取得路徑的檔名與目錄名稱 basename etc...

鳥哥私房菜 基礎篇(1)

linux的核心版本 什麼是linux 用linux做什麼呢 企業環境 個人環境 netman主筆的基礎文章 磁碟組成 主引導分割槽 mbr 可以安裝引導加在程式的地方,開機時主動讀取該區內容,系統才會知道你的程式放在 且如何進行開機,446bytes 分割槽表 記錄整塊磁碟分割槽的狀態,64byt...