Print a file's last modified date in Bash

后端 未结 10 2139
难免孤独
难免孤独 2020-11-29 18:01

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

10条回答
  •  遥遥无期
    2020-11-29 18:30

    You can use:

    ls -lrt filename |awk '{print "%02d",$7}'
    

    This will display the date in 2 digits.

    If between 1 to 9 it adds "0" prefix to it and converts to 01 - 09.

    Hope this meets the expectation.

提交回复
热议问题