.png)
일상적인 개발 작업의 일부로(OS 10.12.3을 실행하는 Mac에서) tail -f *
터미널의 로그 폴더에서 실행합니다. 폴더에는 약 15개의 파일이 포함되어 있습니다. 변경 사항을 모니터링하기 위해 이 명령을 어떻게 변경할 수 있습니까?하나를 제외한 모든 파일에서 *
? 제외하고 싶은 유일한 파일이 *
이라고 가정해 보겠습니다 Repetitive.log
.
매우 기본적인 질문에 대해 사과드립니다. 주위를 둘러보았으나 중복된 질문은 보이지 않았습니다. 다음에서 다시 게시됨https://stackoverflow.com/questions/42815599/exclude-files-from-the-catchall-symbol
답변1
bash
셸로 사용하는 경우 환경 변수를 GLOBIGNORE
콜론으로 구분된 패턴 목록으로 설정하세요.~ 아니다쉘이 글로빙할 때 일치합니다.예를 들어
$ export GLOBIGNORE=Repetitive.log
$ export GLOBIGNORE=somefile:anotherfile:abc*
에서 man bash
:
GLOBIGNORE
A colon-separated list of patterns defining the set of
filenames to be ignored by pathname expansion. If a file-
name matched by a pathname expansion pattern also matches
one of the patterns in GLOBIGNORE, it is removed from the
list of matches.
답변2
xargs
당신의 친구입니다! 그렇지 않은 경우 find
에도 도움이 될 수 있습니다.
다음은 확장된 패턴 일치를 사용 xargs
하는 네 가지 접근 방식입니다 .find ... -exec
다음을 xargs
통해 사용ls
grep
ls | grep -v Repetitive.log | xargs tail -f
xargs
다음을 통해 사용find
find . -maxdepth 1 ! -name Repetitive.log | xargs tail -f
인수 find
와 함께 사용-exec
find . -maxdepth 1 ! -name Repetitive.log -exec tail -f {} \;
확장된 패턴 일치 사용bash
훌륭한 답변, 다음에서 가져옴https://stackoverflow.com/a/19429723/1862762.
shopt -s extglob
tail -f /directory/of/logfiles/!(Repetitive.log)
메모
이 작업에서는 해당 파일 이름이 태그된 xargs
출력을 제공하는 방식을 선호합니다 . tail
사용하는 것이 더 직관적 ls
이고 grep
기억하기 쉬운 것 같습니다.