linuxcommand-linerecent-documents

Linux command most recent non soft link file


Linux command: I am using following command which returns the latest file name in the directory.

ls -Art | tail -n 1

When i run this command it returns me latest file changed which is actually soft link, i wants to ignore soft link in my result, and wants to get file names other then soft link how can i do that any quick help appreciated.

May be can i specify regex matched latest file file name is

rum-12.53.2.war

Solution

  • -- Latest file in directory without softlink

    ls -ArtL | tail -n 1
    

    -- Latest file without extension

    ls -ArtL | sed 's/\(.*\)\..*/\1/' | tail -n 1