이개외않되/Linux / / 2023. 6. 5. 12:58

"Linux find -exec 생략" 에 대한 정리

728x90

🐋 문제

리눅스 기초연습문제이당
find 명령어를 통해서 / 내에서 소유자가 user 인 파일들을 모두 찾아서 자세하게 출력하시오.

  • 내 풀이
    • find ~ -user user -exec ls -l {}\;
  • 정답 풀이
    • find / -user user -ls


🐋 궁금증

  • find 를 사용할때 find한 값을 -exec를 사용해서 {} 담아서 사용하는걸로 알고 있는데
    정답풀이에는 어떻게 바로 -ls를 사용했을까? ( 심지어 ls -l 상세보기로 나옴 )
  • find-user옵션만 가능한걸까?
  • 해당 내용이 man 어디에 적혀있는가?


👻 정리

  • -exec를 생략? 할 수있는 명령어가 몇개 존재한다.
  • -name-exec없이 -ls가 써지길래 신기해 했는데 사실 -ls가 특이한 녀석이였다
    • -exec rm 말고 -delete도 가능
  • man 페이지 EXPRESSION / Operators 에 적혀있다.

man find

   Operators  
          Operators join together the other items within the expression.  They include for  ex‐  
          ample  -o  (meaning  logical  OR) and -a (meaning logical AND).  Where an operator is  
          missing, -a is assumed.  

   The -print action is performed on all files for which the whole expression is  true,  unless  
   it  contains an action other than -prune or -quit.  Actions which inhibit the default -print  
   are -delete, -exec, -execdir, -ok, -okdir, -fls, -fprint, -fprintf, -ls, -print and -printf.  

   The -delete action also acts like an option (since it implies -depth).  
연산자  
연산자는 식 내의 다른 항목을 결합합니다. 그들은 예를 들어 포함합니다  
ample -o(논리적 OR을 의미) 및 -a(논리적 AND를 의미). 작업자가 있는 위치  
결측값, -a를 가정합니다.


   -print 작업은 다음과 같은 경우를 제외하고 전체 식이 참인 모든 파일에 대해 수행됩니다  
   -prune 또는 -prune 이외의 작업이 포함되어 있습니다.  기본 인쇄를 금지하는 작업  
   -delete, -exec, -execdir, -ok, -okdir, -fls, -fprint, -fprint, -ls, -print 및 -printf입니다.  

   -delete 액션은 -depth를 의미하므로 옵션처럼 작동합니다.  
  • 네이버 블로그 공유
  • 네이버 밴드 공유
  • 페이스북 공유
  • 카카오스토리 공유