Find the answer to your Linux question:
Results 1 to 9 of 9
I know how to find and display file by modification time by (ls –g –t) but is there any way to put number of day from this specific number what ...
  1. #1
    Just Joined!
    Join Date
    Jul 2007
    Posts
    31

    Question How to display file by specific input period of time ?

    I know how to find and display file by modification time by (ls –g –t)
    but is there any way to put number of day from this specific number what is the modification in this specific period
    for example if I put 30 it will display all file in last 30 day(month)
    can you help me please ?

  2. #2
    Linux User
    Join Date
    Jul 2004
    Location
    Poland
    Posts
    368
    Try "find -mtime -n" where n is the number of days, like find -mtime 30 in your example.
    "I don't know what I'm running from
    And I don't know where I'm running to
    There's something deep and strange inside of me I see"

  3. #3
    Just Joined!
    Join Date
    Jul 2007
    Posts
    31

    iIt work but it does s not display like “ls” how I convert it to display like list

    It work but it does s not display like “ls” how I convert it to display like list I mean column by column

  4. #4
    Linux User
    Join Date
    Jul 2004
    Location
    Poland
    Posts
    368
    Pipe the output of find to ls -lg, for example:
    Code:
    find -mtime -1 | xargs ls -tg
    (the xargs reads its input and appends the lines after the ls -tg, so that the ls will be invoked with files from find as its arguments). I'm not sure if it handles the subdirectory the way you want them.
    "I don't know what I'm running from
    And I don't know where I'm running to
    There's something deep and strange inside of me I see"

  5. #5
    Just Joined!
    Join Date
    Jul 2007
    Posts
    31

    Unhappy Thanks Mr. Kyku I appreciate your help but unfortunately it does not work properly

    Thanks Mr. Kyku I appreciate your help but unfortunately it does not work properly

    When I Pipe the output of find to ls -lg it will not consider the input Number it will sort All file regardless input number for example when I put
    find -mtime -30 | xargs ls -tg
    It gives me all file from 2007, 2006, 2005......2000 and so on.
    Which is not handles what I want I mean it should display only file in the period from
    30 days (1 month) like from 30 May until now 30 July

    Also it is not handles subdirectory the way I want them. It sort only file in the same subdirectory but I want all file from all subdirectory to be arranged together

  6. #6
    Just Joined!
    Join Date
    Jul 2007
    Posts
    31
    #!/bin/csh -f
    echo "" > tmpfile
    foreach priod ( 720 580 360 270 180 90 )
    set fsize = `find -mtime priod | xargs ls -tg | awk '{ size += $4 } END {print size}' `
    echo " ${priod} ${fsize}" >> tmpfile
    end
    end

    find: invalid argument `priod' to `-mtime'
    find: invalid argument `priod' to `-mtime'
    find: invalid argument `priod' to `-mtime'
    find: invalid argument `priod' to `-mtime'
    find: invalid argument `priod' to `-mtime'
    find: invalid argument `priod' to `-mtime'
    end: Not in while/foreach.

  7. #7
    Linux User
    Join Date
    Jul 2004
    Location
    Poland
    Posts
    368
    Quote Originally Posted by alivip View Post
    #!/bin/csh -f
    echo "" > tmpfile
    foreach priod ( 720 580 360 270 180 90 )
    set fsize = `find -mtime priod | xargs ls -tg | awk '{ size += $4 } END {print size}' `
    echo " ${priod} ${fsize}" >> tmpfile
    end
    end

    find: invalid argument `priod' to `-mtime'
    find: invalid argument `priod' to `-mtime'
    find: invalid argument `priod' to `-mtime'
    find: invalid argument `priod' to `-mtime'
    find: invalid argument `priod' to `-mtime'
    find: invalid argument `priod' to `-mtime'
    end: Not in while/foreach.
    Shouldn't it be find -mtime ${priod}
    BTW I believe the subdirectory problem can eliminated by adding -type f to find. This way it'll only list regular files.
    "I don't know what I'm running from
    And I don't know where I'm running to
    There's something deep and strange inside of me I see"

  8. #8
    Just Joined!
    Join Date
    Jul 2007
    Posts
    31

    Question It is ok now but gove me wrong answare calculation is not right

    It is ok now but gove me wrong answare calculation is not right
    I made this modification

    #!/bin/csh -f
    echo "" > tmpfile
    foreach priod ( 720 580 360 270 180 90 )
    set fsize = `find -mtime ${priod} -type f | xargs ls -tg | awk '{ size += $4 } END {print size}' `
    echo " ${priod} ${fsize}" >> tmpfile
    end

  9. #9
    Just Joined!
    Join Date
    Jul 2007
    Posts
    31
    echo "" > tmpfile
    foreach priod ( 720 580 360 270 180 90 )
    set fsize = `find -mtime ${priod} -type f | xargs ls -tg | awk '{ size += $4 } END {print size}' `
    echo " ${priod} ${fsize}" >> tmpfile
    end

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
...