
중첩된 디렉터리를 제외하도록 두 번째 지시문의 패턴을 수정하려면 어떻게 해야 합니까? (이것은 내용이 아닌 ls
만 반환합니다 ).foo.mp4
bar:
$ ls *
foo.mp4 foo.ogg
bar:
bar.ogg
$ shopt -s extglob
$ ls !(*.ogg)
foo.mp4
bar:
bar.ogg
PS: 저는 OS X를 사용하고 있습니다.
답변1
.Use find
대신 사용하면 하나 이상의 glob 표현식을 제외할 수 있습니다. 귀하의 예(및 OSX)에서는 다음을 수행할 수 있습니다.ls
find
find * -depth 0 -type f ! -name '*.ogg' -ls
다음과 같은 결과가 생성됩니다 ls -l
(주어진 파일에만 해당 -type f
).
66294163 0 -rw-r--r-- 1 tom wheel 0 Sep 9 20:12 foo.mp4
OSX의 경우 첫 번째 열은 inode 값이고 그 다음은 링크 수입니다. find
다음과 같이 많은 목록 옵션을 제공하지 않습니다 ls
.
$ ls -l
total 0
drwx------ 3 thomas wheel 102 Sep 9 15:33 com.apple.launchd.OFStJ79qtq
drwx------ 3 thomas wheel 102 Sep 9 15:33 com.apple.launchd.VQsV1ae6bI
drwx------ 3 thomas wheel 102 Sep 9 15:33 com.apple.launchd.e6HBMt2vnS
drwx------ 3 thomas wheel 102 Sep 9 15:33 com.apple.launchd.he9U4OAIMI
-rw-r--r-- 1 tom wheel 0 Sep 9 20:12 foo.mp4
-rw-r--r-- 1 tom wheel 0 Sep 9 20:12 foo.ogg
하지만 효과가 있을 수도 있습니다.
답변2
나는 무엇을 생각하고 있습니까?
$ ls *.!(ogg)
foo.mp4