4 Replies Latest reply: Apr 4, 2013 10:10 AM by Catch-22 RSS

    File date and  File size find?

    user8053012
      Date of the file created in Linux How do I know that, and how many MB or GB.
      Is there a command?

      For example, how could I get is as follows

      4.0M Mar 28 2011 aaaa
      74.0MFeb 20 2013 test
      164.0M Jun 27 2011 axis2-1.4.1
        • 1. Re: File date and  File size find?
          Bjoern Rost
          ls -lh
          the l-flag returns long output including size and last modification time and the h-flag converts bytes into human-readable megabytes or gigabytes. Also note that the date returned is not (generally) the creation date but the time of last modification.

          cheers
          bjoern
          • 2. Re: File date and  File size find?
            user8053012
            gives the following result.

            [a@dtest1 test]$ ls -lh
            total 980K
            drwxr-xr-x 5 a app 4.0K Apr 3 14:13 buildlib
            -rw-r--r-- 1 a app 80K Apr 1 11:38 cacerts
            -rw-r--r-- 1 a app 76K Apr 1 14:30 cacerts_ab


            How many are created and how many mb in size.
            The following does not correctly.
            • 3. Re: File date and  File size find?
              user8053012 wrote:
              gives the following result.

              [a@dtest1 test]$ ls -lh
              total 980K
              drwxr-xr-x 5 a app 4.0K Apr 3 14:13 buildlib
              -rw-r--r-- 1 a app 80K Apr 1 11:38 cacerts
              -rw-r--r-- 1 a app 76K Apr 1 14:30 cacerts_ab


              How many are created and how many mb in size.
              The following does not correctly.
              Yes it does display the information correctly.

              You are being told that for the user you currently happen to be when you ran that command, there is one directory and two files. The total of 980K represents what your current user has permissions to see plus other non-visible items (which could be hidden files and/or hidden directories of files).

              I suggest you go read the man pages for ls to get guidance on more command switches available and you might also try the same commands after you change to root user. Then compare the different outputs.
              • 4. Re: File date and  File size find?
                Catch-22
                If you want to know just the file system block usage for directories and files you can use the du command. For more advanced functions, the find command is useful.

                The command "du -s ./*" will show you a summary of files and directories in the current directory hierarchy. You can use "du -a" to see each file or even show the 10 largest files using "du -a /var | sort -n -r | head -n 10", for instance.

                The "du" command does not show you the date. However, depending on what you are trying to achieve, there are other commands that are useful. For example: To find files that are older than 1 month and are larger than 1 GB "find / -size +1G -mtime 30 -ls". Find is a very versatile tool that provides many search options and can apply custom commands to its output.