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

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

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

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

    “20世紀音楽”の発展に貢献した指揮者、クーセヴィツキー。その偉業とは【クラシック今日は何の日?】
    2024-06-03

    「2億円トイレ」のイメージ図など公開 大阪・関西万博
    2024-06-04

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

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

    akakilikeの新作ダンス公演『希望の家』が松本・東京の2都市で上演へ
    2024-06-04

    開館10周年を記念。「広重 ─摺の極─」があべのハルカス美術館で開催へ
    2024-06-05

    口腔ケアで高齢者を守ろう 「おとなの歯磨き」訪問歯科医が出版
    2024-06-04

    105歳で死去した画家弥勒祐徳さん おごらず、黙々と、ひたすらに神楽など描く
    2024-06-05

    3日間限定発売! 名作パントンチェアが新たな魅力を纏った限定カラーで登場。
    2024-06-05

    「再会長江」北京で特別上映 竹内監督のトークイベントも
    2024-06-04

    田名網敬一の巨大インスタレーションが、世界初大規模回顧展「田名網敬一 記憶の冒険」に登場。国立新美術館で8月7日から
    2024-06-06

    「Osaka Art & Design 2024」(大阪市内)開幕レポート。何気ない日常のなかで多様なカルチャーに触れる
    2024-06-06

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

    なぜ、いま「先住民の現代アート」なのか? 『美術手帖』2024年7月号は、「先住民の現代アート」特集
    2024-06-06

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

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

    ©  Dopu Box
    💛