• Online Tools
  • - Calculators
    • Character Count
  • - Download
    • TikTok Download
    • DouYin Download
  • - Web Tools
    • BASE64
    • Base64 to Image
    • Image to Base64
    • URL Encoding
    • JavaScript
    • Timestamp
    • Unicode Converter
    • JSON Format
    • Modify Extension
    • Make List
    • CSS Optimizer
  • - Encryption Tools
    • MD5 Encryption
    • Random Generator
  • - Image Tools
    • Image Compression
    • QR Code Generator
    • QR Code Reader
    • Wallpaper Preview
  • - Info Sheets
    • Blood Type Heredity
    • Clothing Sizes
  • [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

Other Tools
  • Character Count TikTok Download DouYin Download BASE64 Base64 to Image Image to Base64 URL Encoding JavaScript Timestamp Unicode Converter JSON Format Modify Extension Make List CSS Optimizer MD5 Encryption Random Generator Image Compression QR Code Generator QR Code Reader Wallpaper Preview Blood Type Heredity Clothing Sizes
  • ブームなぜ起きた? 東京国立近代美術館で「ハニワと土偶の近代」展
    2024-05-30

    “ひばり”の愛称にふさわしい美しいメロディ。ハイドンの『弦楽四重奏曲第67番』【クラシック今日は何の日?】
    2024-05-30

    授業中の生徒や住民が弾道ミサイル飛来を想定した避難訓練 福島・須賀川桐陽高
    2024-05-31

    入試問題は白黒です 「わかりやすさ」「カラフル」は逆効果、自分で図を書くべし 桜井信一の攻める中学受験
    2024-05-31

    鎌倉幕府の地頭から海の武士団・松浦党に…古文書群「青方文書」からみる中世の漁業や製塩事情
    2024-06-01

    デザインジャーナリストによる新しいデザイン誌の登場です!
    2024-06-01

    まだ無名だった作曲家エルガーが、婚約の贈り物として捧げた名曲【クラシック今日は何の日?】
    2024-06-01

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

    三姉妹が温泉旅行で取っ組み合いの大げんか うっとうしくてめんどうくさい家族愛描く「お母さんが一緒」
    2024-06-02

    中国でドラえもん映画が興行首位 国際こどもの日に12億円
    2024-06-03

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

    IT国家の最先端研究を知って 奈良・宇陀市がエストニアへの短期留学事業
    2024-06-04

    GROUP「島をつくる | Planning Another Island」(マイナビアートスクエア)開幕レポート。高層ビルのなかで建築をコンポストする
    2024-06-05

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

    国際博物館の日、今年のテーマは「学びと研究のための博物館」
    2024-06-04

    ビル・エヴァンスの名言「才能なんて取るに足りない」【本と名言365】
    2024-06-05

    美しくて“かわいい”結びの技  1400年の歴史を誇る「水引」の可能性を探って
    2024-06-06

    そごう・西武が百貨店として初めてNFTマーケット開設、NFT作品約100点を発売
    2024-06-06

    藤井八冠、5連覇へ白星発進 将棋棋聖戦、山崎八段破る
    2024-06-06

    佐渡金山「情報照会」と勧告 世界遺産登録に可能性残す
    2024-06-06

    ©  Dopu Box
    💛