Skip to content

Instantly share code, notes, and snippets.

@omega-takai
Created February 17, 2023 04:37
Show Gist options
  • Save omega-takai/cec29ef37bce6840a5630d38223e41f6 to your computer and use it in GitHub Desktop.
Save omega-takai/cec29ef37bce6840a5630d38223e41f6 to your computer and use it in GitHub Desktop.
$ git grep 'time_t' -- '*.[ch]'

Looks for time_t in all tracked .c and .h files in the working directory and its subdirectories.

$ git grep -e '#define' --and \( -e MAX_PATH -e PATH_MAX \)

Looks for a line that has #define and either MAX_PATH or PATH_MAX.

$ git grep --all-match -e NODE -e Unexpected

Looks for a line that has NODE or Unexpected in files that have lines that match both.

$ git grep solution -- :^Documentation

Looks for solution, excluding files in Documentation.

$ git grep -e 'export' --and \( --not -e 'interface' \) --and \( --not -e 'export type' \) -- ':*.tsx' ':!*.stories.tsx' ':!*.test.tsx'
$ git grep -n 'hogehoge' -- ':*.jsx' ':*.js' ':*.tsx' ':*.ts'

Refs

@omega-takai
Copy link
Author

サンプル

$ git grep -n -E "(\.png|\.jpg|\.svg)" -- ':*.jsx' ':*.js' ':*.tsx' ':*.ts' ':!*.esm.js'
$ git grep -n -e 'http' --and \( --not -e 'xmlns' \) --and \( --not -e 'reactjs' \) --and \( --not -e 'fb.me' \) -- ':*.jsx' ':*.js' ':*.tsx' ':*.ts' ':!*.esm.js' ':^src/__test__/' ':^src/__mock__/'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment