Bash find command Modification Date Latest File Output

Output Latest File by Modification Date Using Bash find Command

Introducing how to filter and output the latest file by modification date using the find command in Linux Bash command line. I tried to do it with ls, but this outputs the date, so find "/path" -printf '%T+ %pn'

Shou Arisaka
1 min read
Nov 11, 2025

Introducing how to filter and output the latest file by modification date using the find command in Linux Bash command line.

I tried to do it with ls, but

ls -Rtald "/mnt/c/Users/user/OneDrive/ドキュメント/ShareX/Screenshots/" | head -n 11

it got complicated, and actually I couldn’t do it.

You can do it with find.

find "/path" -printf '%T+ %p\n' | sort -r | head -n 1
2018-09-02+04:24:51.0869511000 /mnt/c/Users/user/OneDrive/ドキュメント/ShareX/Screenshots/2018-09/ShareX_ScreenShot_b3e5c560-30ec-48b2-9d1f-b943a0d5e9bb.png

This outputs the date, so

find "/path" -printf '%T+ %p\n' | sort -r | head -n 1 | sed -Ee "s/^.*(\/mnt.*\.(jpg|png))/\1/g")

You can change the output like this.

Share this article

Shou Arisaka Nov 11, 2025

🔗 Copy Links