find command - Unix

This is a discussion on find command - Unix ; Hello., i am trying to accomplish is; i have a dir and inside that i have certain files. files keep arriving in that dir. the dir has lot of files but i have to process only those files that arrive ...

+ Reply to Thread
Results 1 to 4 of 4

Thread: find command

  1. find command

    Hello.,

    i am trying to accomplish is;

    i have a dir and inside that i have certain files. files keep arriving
    in that dir. the dir has lot of files but i have to process only those
    files that arrive today.

    for eg: today is mar 21 so i have to process only those files that
    arrived today.

    each dir comes with a prefix TNT and suffix as ctl*
    so i tried to use this command;
    ls -ltr TNT.*.*.*.ctl* | awk -F" " '{print $6" "$7 }'
    the output is:
    Feb 27
    Feb 27
    Feb 27
    Feb 27
    Feb 28
    Feb 28
    Mar 9
    Mar 21
    Mar 21

    now i know that today ( Mar 21) there are 2 files that arrived. so i
    have to pick up ( or find ) these 2 files that arrived today and
    process them.

    can anyone help me plz

    thanks
    pavi


  2. Re: find command

    pawan_test wrote:
    > i have a dir and inside that i have certain files. files keep arriving
    > in that dir. the dir has lot of files but i have to process only those
    > files that arrive today.


    If your find(1) supports -cnewer, then you can use touch(1) to create
    timestamp reference file(s) and then use -cnewer and/or ! -cnewer with
    find(1) to isolate the relevant file(s).

    If your find(1) doesn't have -cnewer, one can write a similar filter
    in perl or C ... I wrote such a utility program in C many years ago.
    Perl might be quite convenient and efficient enough, and it would
    probably also be much easier to specify in Perl to look for time(s)
    corresponding to a specific date.

    In any case, don't forget to consider timezone, leap seconds, and
    precise boundary conditions. (Presumably any given file should belong
    to exactly and only one day, and it should be the expected day.)


  3. Re: find command

    2006-03-30, 03:26(-08), Michael Paoli:
    > pawan_test wrote:
    >> i have a dir and inside that i have certain files. files keep arriving
    >> in that dir. the dir has lot of files but i have to process only those
    >> files that arrive today.

    >
    > If your find(1) supports -cnewer, then you can use touch(1) to create
    > timestamp reference file(s) and then use -cnewer and/or ! -cnewer with
    > find(1) to isolate the relevant file(s).

    [...]

    Why would you use -cnewer. Why not -newer which every find has?

    --
    Stéphane

  4. Re: find command

    Stephane CHAZELAS wrote:
    > 2006-03-30, 03:26(-08), Michael Paoli:
    > > pawan_test wrote:
    > >> i have a dir and inside that i have certain files. files keep arriving
    > >> in that dir. the dir has lot of files but i have to process only those
    > >> files that arrive today.

    > > If your find(1) supports -cnewer, then you can use touch(1) to create
    > > timestamp reference file(s) and then use -cnewer and/or ! -cnewer with
    > > find(1) to isolate the relevant file(s).

    > Why would you use -cnewer. Why not -newer which every find has?


    mtime and atime are user settable. E.g. if someone extracts a file
    from an archive (e.g. a tar or cpio archive) and preserves the mtime
    from the file in the archive, it may have quite an old mtime. Similar
    may occur if touch(1) or utime(2) are used, such as in copying a file
    with an older mtime, and preserving that mtime.


+ Reply to Thread