• Outils en Ligne
  • - Calculatrices
    • Compteur de Caractères
  • - Téléchargement
    • Téléchargement TikTok
    • Téléchargement Douyin
  • - Outils Web
    • BASE64
    • Base64 vers image
    • Image vers Base64
    • Encodage URL
    • JavaScript
    • Timestamp
    • Convertisseur Unicode
    • Formatage JSON
    • Modifier l’Extension
    • Créer une Liste
    • Optimiseur CSS
  • - Outils de Chiffrement
    • Chiffrement MD5
    • Générateur Aléatoire
  • - Outils d’Image
    • Compression d’Images
    • Générateur de QR Code
    • Lecteur de QR Code
    • Prévisualisation de Fond
  • - Fiches d'information
    • Hérédité du Groupe Sanguin
    • Tailles Vêtements
  • [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

Autres Outils
  • Compteur de Caractères Téléchargement TikTok Téléchargement Douyin BASE64 Base64 vers image Image vers Base64 Encodage URL JavaScript Timestamp Convertisseur Unicode Formatage JSON Modifier l’Extension Créer une Liste Optimiseur CSS Chiffrement MD5 Générateur Aléatoire Compression d’Images Générateur de QR Code Lecteur de QR Code Prévisualisation de Fond Hérédité du Groupe Sanguin Tailles Vêtements
  • レノンのギター4.5億円 ビートルズ関連最高落札額
    2024-05-30

    被害者「問題解決には程遠い」 旧ジャニーズ被害者らが会見
    2024-05-29

    社長「関係者や視聴者不安にさせた」と謝罪
    2024-05-30

    将棋叡王戦、藤井が勝ち最終局へ
    2024-05-30

    現代詩の「中原中也賞」、俳句で培われた言語感覚…「新たな音やリズム」ジャンルを往来し追求
    2024-06-02

    ポール・オースターの名言「けれどオニオンパイの味は…」【本と名言365】
    2024-06-02

    大阪はアートとデザインの街となるか? Osaka Art & Design 2024の見どころをレポート
    2024-06-03

    小学館「作家の意向第一に協議」 映像化指針、ドラマ原作者死去で
    2024-06-03

    道後温泉の記憶を継承するアート 大竹伸朗が“描き”重要文化財を守ったテント膜「熱景」の再生
    2024-06-03

    「君たちはどう生きるか」展 第二部 レイアウト編(三鷹の森ジブリ美術館)レポート。絵を描くことの営為、そして苦悩も見せる
    2024-06-04

    「TRIO パリ・東京・大阪 モダンアート・コレクション」(東京国立近代美術館)開幕レポート。トリオで再発見する3館のコレクション
    2024-06-05

    今週末に見たい展覧会ベスト12。山武市百年後芸術祭、版画の青春、北斎に三島喜美代まで
    2024-06-04

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

    「台北當代2024」開幕レポート。「台湾マーケットのニーズに応えるプラットフォームに」
    2024-06-04

    多摩美術大学がAIやサーキュラーなど5つの最先端のテーマを研究するプラットフォームをスタート
    2024-06-04

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

    ご当地体操「いちょう体操」に小学生の指導委員が誕生 「体がのびやかに動く」
    2024-06-06

    「江戸期より後の遺構」 世界遺産目指す佐渡の金山、一部除外勧告
    2024-06-06

    美術家藤井光さん個展「終戦の日/WAR IS OVER」 希望か絶望か…大分・佐伯の地下弾薬庫跡にこだまする泣き声
    2024-06-07

    もしあの時に戻れたら…歌人・穂村弘が話題書『迷子手帳』で明かす、今も忘れられない「失敗」
    2024-06-07

    ©  Dopu Box
    💛