Linux find grep 명령어

find 파일 찾기

# find {위치} -type f -name '{파일명}'

# find {위치} -type d -name '{디렉토리명}'

# find . | xargs grep '{파일명}'

# find . -type f -name "*.html" -a -name "in*" (expr1 -and expr2)

# find . -type f -name "*.html" -o -name "in*" (expr1 -or expr2)

# find . -empty -exec rm {} \; (빈 파일 삭제)

# find . -type f -name "*.txt" -exec grep rm {} \; (txt파일 삭제)

# find . -type f -name "*.txt" -exec grep '{키워드}' {} \; (txt파일 중 키워드 찾기)

# find . -type f -name "*" -exec grep -Hn --color '{키워드}' {} \;

# find . -name "*.php" -exec perl -pi -e 's/{찾을문자}/{바꿀문자}/g' {} \;

xargs 의 역할

xargs는 파이프를 통해 넘어온 find명령의 결과물을 다음 명령어에 매개변수로 던져주는 역할

답글 남기기

이메일 주소는 공개되지 않습니다. 필수 필드는 *로 표시됩니다