WindowsPowerShellSelect-String검색
grep 대신 Select-String 으로 텍스트 검색
변수 입력2개
아래 프롬프트를 복사해 AI에 붙여넣어. {{PATTERN}} 에 찾을 글자를, {{SEARCH_DIR}} 에 검색할 폴더를 바꾸면 된다.
나는 Windows를 사용하고 있어.
{{SEARCH_DIR}} 폴더 안의 파일들에서 "{{PATTERN}}" 이라는 글자가 들어간 곳을 찾고 싶어.참고 — 바로 쓸 수 있는 명령어
폴더를 재귀적으로 검색:
Get-ChildItem {{SEARCH_DIR}} -Recurse -File | Select-String -Pattern "{{PATTERN}}"매치된 파일 경로만 출력:
Get-ChildItem {{SEARCH_DIR}} -Recurse -File | Select-String -Pattern "{{PATTERN}}" -List | Select-Object Path대소문자 구분해서 검색:
Get-ChildItem {{SEARCH_DIR}} -Recurse -File | Select-String -Pattern "{{PATTERN}}" -CaseSensitiveclassic findstr(하위 폴더 /s):
findstr /s /i "{{PATTERN}}" {{SEARCH_DIR}}\*.*Select-String 은 기본적으로 대소문자를 구분하지 않는다. 대량 파일에는 -List 로 파일당 첫 매치만 뽑으면 빠르다.
댓글 0개
아직 댓글이 없습니다.
