• 線上工具
  • - 計算器
    • 字元計數
  • - 下載
    • TikTok 下載
    • 抖音下載
  • - 網路工具
    • BASE64
    • Base64 轉圖片
    • 圖片轉 Base64
    • URL 編碼
    • JavaScript
    • 時間戳
    • Unicode 轉換器
    • JSON 格式化
    • 修改副檔名
    • 製作列表
    • CSS 優化器
  • - 加密工具
    • MD5 加密
    • 隨機生成器
  • - 圖像工具
    • 圖像壓縮
    • QR 碼生成器
    • QR 碼識別器
    • 壁紙預覽
  • - 資訊表
    • 血型遺傳
    • 服裝尺寸
  • [email protected]
DopuBox
  • English
  • Español
  • Français
  • 日本語
  • 한국어
  • 简体中文
  • 繁體中文
全部 ニュース Meta Code 文化・アート
15個のLinux Grepコマンド使用例(実用、常用)
2021-11-25

コードのコピー
$ cat demo_file
THIS LINE IS THE 1ST UPPER CASE LINE IN THIS FILE. this line is the 1st lower case line in this file.
This Line Has All Its First Character Of The Word With Upper Case.
Two lines above this line is empty. And this is the last line.
例01:指定した文字列を単一ファイルから検索する
コードのコピー $ grep "this" demo_file
this line is the 1st lower case line in this file.
Two lines above this line is empty. 例02:指定した文字列を複数のファイルから検索する
コードのコピー

$ cp demo_file demo_file1

$ grep "this" demo_* demo_file:this line is the 1st lower case line in this file.
demo_file:Two lines above this line is empty.
demo_file:And this is the last line.
demo_file1:this line is the 1st lower case line in this file.
demo_file1:Two lines above this line is empty. demo_file1:And this is the last line.
例03:大文字と小文字を無視してgrep-iを使用
コードのコピー $ grep -i "the" demo_file
THIS LINE IS THE 1ST UPPER CASE LINE IN THIS FILE.
this line is the 1st lower case line in this file. This Line Has All Its First Character Of The Word With Upper Case.
And this is the last line.
例04:ファイルに正規表現をマッチさせる コードのコピー
$ grep "lines.*empty" demo_file
Two lines above this line is empty. Grepドキュメントから見ると、正規表現は次の一致操作に従う必要があります。
1.?         The preceding item is optional and matched at most once.
2.*          The preceding item will be matched zero or more times. 3.+         The preceding item will be matched one or more times.
4.{n}      The preceding item is matched exactly n times.
5.{n,}     The preceding item is matched n or more times. 6.{,m}    The preceding item is matched at most m times.
7.{n,m}  The preceding item is matched at least n times, but not more than m times.
例05:grep-wで完全一致を検索し、サブ文字列を含まない コードのコピー
$ grep -i "is" demo_file
THIS LINE IS THE 1ST UPPER CASE LINE IN THIS FILE. this line is the 1st lower case line in this file. This Line Has All Its First Character Of The Word With Upper Case.
Two lines above this line is empty.
And this is the last line. コードのコピー
$ grep -iw "is" demo_file
THIS LINE IS THE 1ST UPPER CASE LINE IN THIS FILE. this line is the 1st lower case line in this file.
Two lines above this line is empty.
And this is the last line. 例06:grep-A,-B,-Cでafter/before/around行を表示する
コードのコピー
$ cat demo_text 4. Vim Word Navigation
You may want to do several navigation in relation to the words, such as:
* e - go to the end of the current word. * E - go to the end of the current WORD.
* b - go to the previous (before) word.
* B - go to the previous (before) WORD. * w - go to the next word.
* W - go to the next WORD.

ソース元URL:https://dopubox.com/article/p/97cee343e18d7f90

其他工具
  • 字元計數 TikTok 下載 抖音下載 BASE64 Base64 轉圖片 圖片轉 Base64 URL 編碼 JavaScript 時間戳 Unicode 轉換器 JSON 格式化 修改副檔名 製作列表 CSS 優化器 MD5 加密 隨機生成器 圖像壓縮 QR 碼生成器 QR 碼識別器 壁紙預覽 血型遺傳 服裝尺寸
  • 美術館の裏側を伝える展覧会「鎌倉別館40周年記念 てあて・まもり・のこす 神奈川県立近代美術館の保存修復」レポート
    2024-05-29

    民藝・イズ・ビューティフル。 日本文化と黒人文化が融合する「アフロ民藝」とは?
    2024-05-30

    意思疎通うまくいかず信頼関係失われた
    2024-05-31

    むのたけじ賞、名称変更 「生前に障害者差別発言」
    2024-05-31

    「ねこクラゲ」被告、脱税認める 原稿優先で申告せず、福岡地裁
    2024-05-31

    作曲家ビゼーの窮地を救った傑作オペラ『真珠採り』の聴きどころは?【クラシック今日は何の日?】
    2024-05-31

    香川県・直島に開館する新たな美術館の正式名称が「直島新美術館」に決定
    2024-06-03

    ニコライ・バーグマンが手がける北欧のジュエリーブランド〈フローラダニカ〉旗艦店が南青山にオープン。
    2024-06-03

    河合隼雄物語賞に八木詠美さん 学芸賞は湯沢規子さん
    2024-06-03

    映画「ゴジラ‐1.0」の震電は「コックピットだけ復元」のはずだった…山崎貴監督がエピソード披露
    2024-06-04

    彫刻の森美術館で「舟越桂 森へ行く日」が開催へ
    2024-06-05

    東京都写真美術館で「今森光彦 にっぽんの里山」が開催へ
    2024-06-04

    特別展「梅津庸一 クリスタルパレス」が国立国際美術館で開催。00年代からの仕事を総覧
    2024-06-04

    「KOGEI Art Fair Kanazawa 2024」開催決定
    2024-06-04

    クールべ《世界の起源》はなぜ攻撃されたのか? ポンピドゥー・センター・メッスで破壊・盗難事件
    2024-06-04

    今年の「アートウィーク東京」は11月に開催。「AWT FOCUS」の監修には片岡真実
    2024-06-04

    「ART OSAKA 2024」が7月18日より開幕。近代建築と現代美術のコラボレーションにも注目
    2024-06-04

    「art stage OSAKA 2024」が9月に開催。大阪・関西万博への機運も醸成
    2024-06-05

    佐渡金山の世界遺産登録、「情報照会」勧告
    2024-06-06

    向田邦子の名言「…これが私の料理のお稽古なのです。」【本と名言365】
    2024-06-07

    ©  Dopu Box
    💛