在Bash中打印文件的最后修改日期

前端之家收集整理的这篇文章主要介绍了在Bash中打印文件的最后修改日期前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我似乎不能找到如何打印出一个文件的日期。我到目前为止能打印出一个目录中的所有文件,但我需要打印出来的日期。

我知道我需要附加日期格式与条目的回声,但所有我找不到正确的格式。

  1. echo "Please type in the directory you want all the files to be listed"
  2.  
  3. read directory
  4.  
  5. for entry in "$directory"/*
  6. do
  7. echo "$entry"
  8. done
你可以使用
stat
命令
  1. stat -c %y "$entry"

更多信息

  1. %y time of last modification,human-readable

猜你在找的Bash相关文章