在Bash中打印文件的最后修改日期 [英] Print a file's last modified date in Bash

查看:80
本文介绍了在Bash中打印文件的最后修改日期的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我似乎找不到打印文件的日期。我能够打印出目录中的所有文件,但是我需要打印出它的日期。

I can't seem to find how to print out the date of a file. I'm so far able to print out all the files in a directory, but I need to print out the dates with it.

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

I know I need to attach a date format with the echo of the entry, but all I can't find the correct format.

echo "Please type in the directory you want all the files to be listed"

read directory 

for entry in "$directory"/*
do
  echo "$entry"
done


推荐答案

您可以使用
stat
command

You can use the stat command

stat -c %y "$entry"

更多信息


%y   time of last modification, human-readable

这篇关于在Bash中打印文件的最后修改日期的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆