• 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-30

    韓国HYBE傘下の代表続投 和解望む意向
    2024-05-31

    あらゆる知識に精通した「天才」が教えてくれた、頭を良くするための新書の読み方と「究極のインプット・アウトプット」の方法
    2024-06-02

    吉田南さん、バイオリン部門6位 エリザベート音楽コン、奈良出身
    2024-06-01

    エリザベートコンクールで吉田さん6位入賞
    2024-06-01

    富士山麓のダイナミックな食材を味わう“奥・山梨”のガストロノミー〈Restaurant SAI 燊〉。
    2024-06-01

    万博無料招待、大阪の学校7割が希望 「不参加」の選択肢ない調査手法に批判も
    2024-06-03

    河合隼雄賞に八木詠美さん「休館日の彼女たち」、湯澤規子さん「焼き芋とドーナツ」
    2024-06-02

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

    アレクサンダー・カルダー個展「カルダー:そよぐ、感じる、日本」が開催
    2024-06-04

    第34回福岡アジア文化賞受賞者が決定。大賞は真鍋大度
    2024-06-04

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

    今週末に見たい展覧会ベスト13。「令和6年 新指定国宝・重要文化財」展から国立西洋美術館の現代美術展、KYOTOGRAPHIEまで
    2024-06-04

    五木ひろし歌手生活60年…ふるさと福井へ恩返しの新曲
    2024-06-04

    「VOCA展」に関するハラスメント防止のためのガイドラインが制定
    2024-06-05

    沙に囲まれた残酷な世界が私たちの社会を浮かび上がらせる。期待の作家が令和の世に送り出す、新たな青春のバイブル!
    2024-06-06

    岡田将生の初ブランド「IN MY DEN」始動、第1弾グッズの受注販売がスタート
    2024-06-06

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

    「さどの島銀河芸術祭2024」が開催。新潟・佐渡島各所で作品を制作展示
    2024-06-06

    ©  Dopu Box
    💛