寻找返回目录中最新文件的命令。
没有看到ls的limit参数…
寻找返回目录中最新文件的命令。
没有看到ls的limit参数…
当前回答
找到前缀为shravan*的文件并查看
less $(ls -Art shravan* | tail -n 1)
其他回答
ls -t | head -n1
这个命令实际上给出了当前工作目录中最新修改的文件或目录。
我使用:
ls -ABrt1——group- directory -first | tail -n1 . ls -ABrt1——group- directory -first | tail -n1 . ls
它只给我文件名,不包括文件夹。
ls -lAtr | tail -1
其他解决方案不包括以“。”开头的文件。
该命令还包括'。'和'..,这可能是也可能不是你想要的:
Ls -latr | tail -1
我喜欢echo *(om[1]) (zsh语法),因为它只给出文件名,而不调用任何其他命令。
根据模式在每个目录中查找最新的文件,例如工作目录的子目录的名称以“tmp”结尾(不区分大小写):
find . -iname \*tmp -type d -exec sh -c "ls -lArt {} | tail -n 1" \;