2016-08-08 7 views
0

내가 속한 디렉토리에 따라이 세 가지 찾기 명령의 결과가 다른 이유는 무엇입니까?Linux 찾기 명령 : 이상한 동작

[email protected]:~$ find /home/daniel/workspace/service/tests/smoke -name *.test 
(result: lists all files named *.test as expected) 

[email protected]:~/workspace$ find /home/daniel/workspace/service/tests/smoke -name *.test 
find: paths must precede expression: service_real_all_tests_possible.test 
Usage: find [-H] [-L] [-P] [-Olevel] [-D help|tree|search|stat|rates|opt|exec] [path...] [expression] 

[email protected]:~/workspace/service$ find /home/daniel/workspace/service/tests/smoke -name *.test 
/home/daniel/workspace/service/tests/smoke/doc.test 
+1

'*'를 인용하지 않았기 때문에 쉘이 먼저 확장합니다. – melpomene

+0

[shellcheck] (http://www.shellcheck.net)을 시도해보십시오. 이건 셸 이상한 점을 많이 지적합니다. –

답변

2

당신은 그렇지 않으면, 쉘 글로브 확장을하고있는이

find /home/daniel/workspace/service/tests/smoke -name "*.test" 

같은 이름을 인용 할 필요가있다.

0

다른 동작은 현재 디렉토리 (하위 디렉토리가 아님)의 파일 수가 *.test과 일치하는지 여부에 따라 다릅니다.

0 matches => find command is executed like you intended 
1 match => find command will only look for files with the same name as the *.test in your current dir. 
>1 match => Your find command is incorrect 
# ignoring special cases like a filename `-name something.test` 

수정 : 따옴표로 *.test을 넣어 또는 \*.test 물품.