• Herramientas Online
  • - Calculadoras
    • Contador de caracteres
  • - Descarga
    • Descarga de TikTok
    • Descarga de DouYin
  • - Herramientas web
    • BASE64
    • Base64 a imagen
    • Imagen a Base64
    • Codificación URL
    • JavaScript
    • Timestamp
    • Convertidor Unicode
    • Formato JSON
    • Modificar extensión
    • Crear lista
    • Optimizador CSS
  • - Herramientas de cifrado
    • Cifrado MD5
    • Generador aleatorio
  • - Herramientas de imagen
    • Compresión de imágenes
    • Generador de código QR
    • Lector de código QR
    • Vista previa de fondo
  • - Hojas de información
    • Herencia de grupo sanguíneo
    • Tallas de ropa
  • [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

Otras Herramientas
  • Contador de caracteres Descarga de TikTok Descarga de DouYin BASE64 Base64 a imagen Imagen a Base64 Codificación URL JavaScript Timestamp Convertidor Unicode Formato JSON Modificar extensión Crear lista Optimizador CSS Cifrado MD5 Generador aleatorio Compresión de imágenes Generador de código QR Lector de código QR Vista previa de fondo Herencia de grupo sanguíneo Tallas de ropa
  • <司書のコレ絶対読んで>「王さまと九人のきょうだい」君島久子訳、赤羽末吉絵
    2024-05-29

    古本屋を巡り、顧みられなくなった作品、作家を生き返らせた九大大学院教授没後20年 教え子や研究仲間を支える「清新な光景」
    2024-05-30

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

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

    ビルケンシュトック、創業から250年の歴史を振り返る2冊を出版
    2024-06-01

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

    【大河ドラマ「光る君へ」本日第22話】紫式部と清少納言は「顔を合わせていなかった」?
    2024-06-01

    「警察密着24時」担当者ら懲戒 テレビ東京、石川社長は3割返上
    2024-06-03

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

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

    特別展 「工芸的美しさの行方―うつわ・包み・装飾」が東京と京都で開催。日本の美術工芸を世界へ 
    2024-06-04

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

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

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

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

    夜の美術館を楽しめる「サマーナイトミュージアム2024」が開催。東京都現代美術館、東京都庭園美術館などで入場料割引も
    2024-06-04

    ユージーン・スタジオが東南アジアに美術館を建設予定。新法人YES__pte.ltdを設立し、インドネシア・ジャカルタに美術館準備室を開設
    2024-06-04

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

    田名網敬一が新作の巨大インスタレーションを発表へ。世界初の大規模回顧展「田名網敬一 記憶の冒険」
    2024-06-06

    子供と行きたいおすすめ美術館【東京編】。子連れ、親子でアートを楽しもう!
    2024-06-06

    ©  Dopu Box
    💛