3

On a Unix server (Sun Solaris), with ls -lrtR I get the list of all the file in my path and its subdirectories with their last update date.

With find . -type f -name "*.sas" I find the list of my .sas files in my path and its subdirectories but without attributes.

Is it possible to have the list of my .sas files in my path and its subdirectories with their last update date?

I tried find / -iname "*.sas" from How to find a file from any directory but it gives me:

find: bad option -iname
find: [-H | -L] path-list predicate-list

I tried find . -type f -name '*.sas'|xargs stat -f '%c %N'|sort from https://unix.stackexchange.com/a/320547/184179, but it gives me:

xargs: Could not exec command: No such file or directory
  • In most cases, citing your system details like FreeBSD, Solaris, GNU Linux and specific versions of your shell (bash/zsh/ksh/tcsh) might be useful – Inian Oct 1 '19 at 8:34
  • @Inian Solaris, added, thanks. – CarLaTeX Oct 1 '19 at 8:44
  • Note that the -iname argument is a non-portable, non-standard GNU extension to the POSIX-standard find utility. – Andrew Henle Oct 1 '19 at 10:07
  • @AndrewHenle I'm not an expert, I tried what I found on the internet – CarLaTeX Oct 1 '19 at 11:16
  • Have you tried find / -type f -name \*.sas -ls? – Lambert Oct 1 '19 at 11:36
1

According to the man page man find the -ls option can be used to show the modification time:

 -ls                 Always  true.  Prints  current  pathname
                     together with its associated statistics.
                     These include (respectively):

                         o    inode number

                         o    size in kilobytes (1024 bytes)

                         o    protection mode

                         o    number of hard links

                         o    user

                         o    group

                         o    size in bytes

                         o    modification time.

So in your case the command find / -type f -name "*.sas" -ls should output something like:

24584    1 -rw-r--r--   1 user staff           0 Oct  1 13:58 ./a.sas
24586    1 -rw-r--r--   1 user staff           0 Oct  1 13:58 ./b.sas
24587    1 -rw-r--r--   1 user staff           0 Oct  1 13:58 ./c.sas
  • It works, thanks! – CarLaTeX Oct 1 '19 at 12:01
  • Also, just for future usage, remember that find also supports -exec command_of_your_choice {} \; which allows you to run command_of_your_choice for each file matching. The {} will be replaced by filename. – binarym Oct 1 '19 at 12:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.