• 온라인 도구
  • - 계산기
    • 문자 수
  • - 다운로드
    • TikTok 다운로드
    • DouYin 다운로드
  • - 웹 도구
    • BASE64
    • Base64→이미지
    • 이미지→Base64
    • URL 인코딩
    • JavaScript
    • 타임스탬프
    • 유니코드 변환기
    • JSON 형식
    • 확장자 수정
    • 목록 만들기
    • CSS 최적화
  • - 암호화 도구
    • MD5 암호화
    • 랜덤 생성기
  • - 이미지 도구
    • 이미지 압축
    • QR 코드 생성기
    • QR 코드 리더
    • 배경 화면 미리보기
  • - 정보 시트
    • 혈액형 유전
    • 의류 사이즈
  • [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

기타 도구
  • 문자 수 TikTok 다운로드 DouYin 다운로드 BASE64 Base64→이미지 이미지→Base64 URL 인코딩 JavaScript 타임스탬프 유니코드 변환기 JSON 형식 확장자 수정 목록 만들기 CSS 최적화 MD5 암호화 랜덤 생성기 이미지 압축 QR 코드 생성기 QR 코드 리더 배경 화면 미리보기 혈액형 유전 의류 사이즈
  • 藤子・F・不二雄の名言「ありそうもない話をありそうに描きたい」【本と名言365】
    2024-05-29

    藤井聡太八冠が勝ち、最終局へ 将棋叡王戦で2勝2敗
    2024-05-31

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

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

    〈テロ事件と「美の復讐」〉15世紀末・イタリア「メディチ家兄弟暗殺計画」とルネサンスの画家たち
    2024-06-01

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

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

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

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

    レイモンド・ローウィの名言「優れたインダストリアルデザインは、…」【本と名言365】
    2024-06-04

    社会的関与の芸術。清水穣評 城戸保「駐車空間、文字景、光画」展/野村浩「Painter」展
    2024-06-04

    特別展「梅津庸一 クリスタルパレス」が国立国際美術館で開催。00年代からの仕事を総覧
    2024-06-04

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

    第55回星雲賞・自由部門に「巨大ロボット展」 日本SFファングループ連合会議
    2024-06-05

    フィギュアスケートにもぴったり! ハチャトゥリアン作曲の『仮面舞踏会』【クラシック今日は何の日?】
    2024-06-06

    安藤忠雄さん設計の美術館名称決まる…香川・直島に2025年オープン
    2024-06-05

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

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

    青森で来年夏に音楽祭 沖澤のどかさんが総監督
    2024-06-06

    書評:「普通にラッセンが好き」と言えない現代美術界へ。原田裕規『評伝クリスチャン・ラッセン 日本に愛された画家』
    2024-06-06

    ©  Dopu Box
    💛