경로의 액세스 권한 나열

경로의 액세스 권한 나열

경로에 액세스 권한을 나열하는 더 좋은 방법(반복 대체 방지)이 있습니까?

echo "/asdf/asd/asdas/asdasd/asdasd/asdwer" | sed -Ee 's#((.*)/.*)#\1\n\2#' \
-e 's#((.*)/.*)#\1\n\2#' -e 's#((.*)/.*)#\1\n\2#' -e 's#((.*)/.*)#\1\n\2#' -e 's#((.*)/.*)#\1\n\2#' -e 's#((.*)/.*)#\1\n\2#' -e 's#((.*)/.*)#\1\n\2#' -e 's#((.*)/.*)#\1\n\2#' -e 's#((.*)/.*)#\1\n\2#' -e 's#((.*)/.*)#\1\n\2#' \
-e 's#((.*)/.*)#\1\n\2#' | sort -u | xargs ls -dl

답변1

작은 쉘 루프가 이를 수행할 수 있습니다:

p=/var/log/messages
while [ $p != "/" ]; do ls -ld "$p"; p=$(dirname "$p"); done; ls -ld "$p"

예제 출력:

-rw-------.  1 root root 241859 Apr 10 09:23 /var/log/messages
drwxr-xr-x. 14 root root   4096 Apr 10 03:32 /var/log
drwxr-xr-x. 26 root root   4096 Dec 13 16:10 /var
dr-xr-xr-x. 30 root root   4096 Dec 13 16:10 /

관련 정보