Find the answer to your Linux question:
Results 1 to 4 of 4
Hi there, I am having trouble writing a script that produces a text file of all the files that have been changed within the last day? Dont really have a ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined! armo's Avatar
    Join Date
    Apr 2006
    Location
    England, UK
    Posts
    2

    Script to Output Txt File Of Changed Files Within The Last Day - Help


    Hi there,

    I am having trouble writing a script that produces a text file of all the files that have been changed within the last day? Dont really have a clue where to start, I am wondering if anybody would be so kind as to help me out with the solution.

    It would be a great help

    Thanks

  2. #2
    drl
    drl is offline
    Linux Engineer drl's Avatar
    Join Date
    Apr 2006
    Location
    Saint Paul, MN, USA / CentOS, Debian, Slackware, {Free, Open, Net}BSD, Solaris
    Posts
    1,304
    Hi.

    I think command find will do what you want. Look at the man page for it ... cheers, drl
    Welcome - get the most out of the forum by reading forum basics and guidelines: click here.
    90% of questions can be answered by using man pages, Quick Search, Advanced Search, Google search, Wikipedia.
    We look forward to helping you with the challenge of the other 10%.
    ( Mn, 2.6.n, AMD-64 3000+, ASUS A8V Deluxe, 1 GB, SATA + IDE, Matrox G400 AGP )

  3. #3
    Just Joined! armo's Avatar
    Join Date
    Apr 2006
    Location
    England, UK
    Posts
    2
    Not on my linux machine at the minute but would the code below produce a list of all the files changed within the last day and how would I print this to a file using fprint -file. Could I have some assistance putting these together?


    Code:
    find  -daystart -ctime
    -daystart
    Measure times (for -amin, -atime, -cmin, -ctime, -mmin, and -mtime) from the beginning of today rather than from 24 hours ago.

    -ctime n
    File's status was last changed n*24 hours ago.
    -fprint file
    True; print the full file name into file file. If file does not exist when find is run, it is created; if it does exist, it is truncated. The file names ``/dev/stdout'' and ``/dev/stderr'' are handled specially; they refer to the standard output and standard error output, respectively.
    http://linux.about.com/od/commands/l/blcmdl1_find.htm

  4. $spacer_open
    $spacer_close
  5. #4
    drl
    drl is offline
    Linux Engineer drl's Avatar
    Join Date
    Apr 2006
    Location
    Saint Paul, MN, USA / CentOS, Debian, Slackware, {Free, Open, Net}BSD, Solaris
    Posts
    1,304
    Hi, armo.

    The first argument for find is the location in your filesystem of where to start. For example, if I wanted to find all the occurrences in my HOME directory and subdirectories for the filename "t1", I could use:

    find $HOME -name t1 -print

    Think of it like a filter: "find $HOME" would locate every file. The little filter "-name t1" says that if the name is "t1", then move to the right, and "-print" will display the pathname. The qualifications that you add from left to right are usually in pairs, the first tells what qualifier you want to use (name, times, etc), the second part of the pair is the value of the item for which you are looking ("t1", as a name, for example). The "-print" is one a few special qualifiers; it is always true, and it causes the pathname to be displayed.

    One of the good things about *nix is that you can try these over and over to continue learning about them.

    Some find commands can get quite complex. I suggest you learn by staying in your home directory at first. Later, if you are looking at all the files in your system, you would start the find command at root:

    find / ...

    and you would need to become root (su, sudo) to be able to read everything without running into read permission problems ... cheers, drl
    Welcome - get the most out of the forum by reading forum basics and guidelines: click here.
    90% of questions can be answered by using man pages, Quick Search, Advanced Search, Google search, Wikipedia.
    We look forward to helping you with the challenge of the other 10%.
    ( Mn, 2.6.n, AMD-64 3000+, ASUS A8V Deluxe, 1 GB, SATA + IDE, Matrox G400 AGP )

Posting Permissions

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