すべてのファイルをリストしたいです(絶対パスの使用)変更された日付順に指定されたディレクトリ(サブディレクトリではない)のファイルのみを表示します。 ls /path_to_dir -t は変更日に基づいてファイルをリストしますが、フルパスを提供しません。追加の説明:私の作業ディレクトリは/home/emirates/Codeです。
私がリストしたい作業ディレクトリから:
- 絶対パス全体を持つファイルのみ
- ファイルの変更順序に応じて
- /var/reports ディレクトリから
- 私の作業ディレクトリは変更される可能性があります。つまり、本番環境ではどこにいても構いません。
ベストアンサー1
そしてzsh
:
print -rC1 -- ${PWD%/}/path_to_dir/*(NDom.) # regular files only
print -rC1 -- ${PWD%/}/path_to_dir/*(NDom^/) # any type of file except
# directory (so includes
# symlinks, fifos, devices,
# sockets... in addition to
# the regular files above)
print -rC1 -- ${PWD%/}/path_to_dir/*(NDom-^/) # any type except directory
# but this time the type is
# determined after symlink
# resolution so would also
# exclude symlinks to
# directories.
print -rC1 -- ${PWD%/}/path_to_dir/*(ND-om^/) # same but also use the
# modification time of the target
# of symlinks when sorting
print -rC1 -- path_to_dir/*(ND-om^/:P) # same but print the real path for each
# file. That is, make sure it's absolute
# and none of the path components
# are symlinks.
${PWD%/}
$PWD
isはyesの場合を処理するので、noを/
取得します。/path_to_dir/files
//path_to_dir/files
これは${PWD%/}/
ただプレフィックスです。比較的パス(例path_to_dir
)は、すでに絶対パス(例)ではなく絶対パスにします/absolute/path_to_dir
。
だからあなたのために/var/reports
使用してくださいprint -rC1 -- /var/reports/*(...)