find . -type f -ls
or
find . -type f | xargs ls -dils
find . -type f | xargs ls -dils | awk '{print $11}'
find `pwd` -type f | xargs ls -dils | awk '{print $11}'
絶対パスにする
find `pwd` -type f | xargs ls -dils | awk '{cmd=sprintf("cksum %s", $11);system(cmd);close(cmd)}'
結果:
136308519 39 /home/syslinks/www/oldhp/include/fileSQL/data/fields.fql
3255405174 505 /home/syslinks/www/oldhp/include/fileSQL/data/news.txt
1933580744 464 /home/syslinks/www/oldhp/include/fileSQL/data/news.txt.2024.12.31
97555143 23940 /home/syslinks/www/oldhp/include/fileSQL/fileSQL.php
136308519 : cksum の結果
39 : ファイルサイズ
awk の中で、コマンドを発行
cmd=....;system(cmd);......;close(cmd);
cmd はこうなる:
cksum /home/fileSQL.php | awk '{printf "%s ", $0}'
結果:
97555143 23940 /home/fileSQL.php #
cksum の結果を改行がなくした
find `pwd` -type f | xargs ls -dils | awk '{cmd=sprintf("cksum %s | awk '{printf "%s ", $0}'", $11);system(cmd);printf "%s\n",$0;close(cmd);}'
を
find `pwd` -type f | xargs ls -dils | awk '{cmd=sprintf("cksum %s | awk '\''{printf \"%%s \", $0}'\''", $11);system(cmd);printf "%s\n",$0;close(cmd);}'
にエスケープ
' -> '\''
" -> \"
%s -> %%s
結果:
136308519 39 /home/data/fields.fql 97435929 4 -rw----r-- 1 syslinks users 39 4月 22 2008 /home/data/fields.fql
3255405174 505 /home/data/news.txt 97435930 4 -rw----r-- 1 syslinks users 505 12月 31 12:33 /home/data/news.txt
1933580744 464 /home/data/news.txt.2024.12.31 97463922 4 -rw----r-- 1 syslinks users 464 4月 22 2008 /home/data/news.txt.2024.12.31
97555143 23940 /home/fileSQL.php 97435928 24 -rw----r-- 1 syslinks users 23940 4月 22 2008 /home/fileSQL.php
あとは、必要なカラムを再出力
find `pwd` -type f \
| xargs ls -dils \
| awk '{cmd=sprintf("cksum %s | awk '\''{printf \"%%s \", $0}'\''", $11);system(cmd);printf "%s\n",$0;close(cmd);}' \
| awk '{printf "%12s %10s %s %s %s %5s %2s %5s %s\n",$1,$2,$6,$8,$9,$11,$12,$13,$3}'
結果:
136308519 39 -rw----r-- syslinks users 4月 22 2008 /home/data/fields.fql
3255405174 505 -rw----r-- syslinks users 12月 31 12:33 /home/data/news.txt
1933580744 464 -rw----r-- syslinks users 4月 22 2008 /home/data/news.txt.2024.12.31
97555143 23940 -rw----r-- syslinks users 4月 22 2008 /home/fileSQL.php
以上。
リンク集
https://www.ibm.com/docs/ja/aix/7.3?topic=files-finding-find-command
https://www.ibm.com/docs/ja/aix/7.3?topic=x-xargs-command
https://www.ibm.com/docs/ja/aix/7.3?topic=c-cksum-command
https://www.ibm.com/docs/ja/aix/7.3?topic=awk-command
https://www.ibm.com/docs/ja/aix/7.3?topic=d-diff-command
https://stackoverflow.com/questions/20646819/how-can-i-pass-variables-from-awk-to-a-shell-command
https://www.tohoho-web.com/ex/awk.html
https://genzouw.com/entry/2021/08/08/085930/2756/
https://www.rough-and-cheap.jp/linux/find_result_formatting/