ディレクトリ一覧をカスタム形式で表示

サブディレクトリーを含めて、一覧をカスタム化して表示する方法です。

パーミッションおよびオーナー、グループとフルパスでディレクトリー表示

$ sudo find / -type d -printf "%M %u %g %p\n"
dr-xr-xr-x root root /
dr-xr-xr-x root root /boot
drwx------ root root /boot/efi
drwx------ root root /boot/efi/EFI
drwx------ root root /boot/efi/EFI/BOOT
drwx------ root root /boot/efi/EFI/almalinux
   ; (省略)

CSV形式で表示(CP932変換付き)

$ sudo find / \
  -type d -printf "%M\t%u\t%g\t%p\n" \
  | sed 's/"/""/g' \
  | awk -F'\t' '{printf "\"%s\",\"%s\",\"%s\",\"%s\"\n",$1,$2,$3,$4}'
  | iconv -f UTF-8 -t CP932
"dr-xr-xr-x","root","root","/"
"dr-xr-xr-x","root","root","/boot"
"drwx------","root","root","/boot/efi"
"drwx------","root","root","/boot/efi/EFI"
"drwx------","root","root","/boot/efi/EFI/BOOT"
"drwx------","root","root","/boot/efi/EFI/almalinux"
   : (省略)

/proc、/sysを除外してCSV形式で表示

$ sudo find / \
  \( -path "/proc" -o -path "/sys" \) -prune -o \
  -type d -printf "%M\t%u\t%g\t%p\n" \
  | sed 's/"/""/g' \
  | awk -F'\t' '{printf "\"%s\",\"%s\",\"%s\",\"%s\"\n",$1,$2,$3,$4}'
"dr-xr-xr-x","root","root","/"
"dr-xr-xr-x","root","root","/boot"
"drwx------","root","root","/boot/efi"
"drwx------","root","root","/boot/efi/EFI"
"drwx------","root","root","/boot/efi/EFI/BOOT"
"drwx------","root","root","/boot/efi/EFI/almalinux"
   : (省略)

ディレクトリーとファイルを一覧表示

$ sudo find / \
  \( -path "/proc" -o -path "/sys" \) -prune -o \
  -printf "%M\t%u\t%g\t%p\n" \
  | sed 's/"/""/g' \
  | awk -F'\t' '{printf "\"%s\",\"%s\",\"%s\",\"%s\"\n",$1,$2,$3,$4}'
"dr-xr-xr-x","root","root","/"
"dr-xr-xr-x","root","root","/boot"
"drwx------","root","root","/boot/efi"
"drwx------","root","root","/boot/efi/EFI"
"drwx------","root","root","/boot/efi/EFI/BOOT"
"-rwx------","root","root","/boot/efi/EFI/BOOT/fbx64.efi"
"-rwx------","root","root","/boot/efi/EFI/BOOT/BOOTX64.EFI"
"drwx------","root","root","/boot/efi/EFI/almalinux"
"-rwx------","root","root","/boot/efi/EFI/almalinux/mmx64.efi"
"-rwx------","root","root","/boot/efi/EFI/almalinux/shim.efi"
"-rwx------","root","root","/boot/efi/EFI/almalinux/shimx64.efi"
"-rwx------","root","root","/boot/efi/EFI/almalinux/grubx64.efi"
"-rwx------","root","root","/boot/efi/EFI/almalinux/shimx64-almalinux.efi"
"-rwx------","root","root","/boot/efi/EFI/almalinux/grub.cfg"
"-rwx------","root","root","/boot/efi/EFI/almalinux/BOOTX64.CSV"

タイトルとURLをコピーしました