tail - Unix

This is a discussion on tail - Unix ; Hi. I want to write a script that watches a file grow with new filenames, and do something with each new file name. However, I cannot use: # mv $(tail -f filenames.txt) archive for example, because tail does not return ...

+ Reply to Thread
Results 1 to 3 of 3

Thread: tail

  1. tail

    Hi.
    I want to write a script that watches a file grow with
    new filenames, and do something with each new file
    name. However, I cannot use:
    # mv $(tail -f filenames.txt) archive
    for example, because tail does not return until it
    gets a EOF. How can I do it?
    -Mike


  2. Re: tail

    In article <1161649631.958035.106290@i42g2000cwa.googlegroups. com>,
    "Mike" wrote:

    > Hi.
    > I want to write a script that watches a file grow with
    > new filenames, and do something with each new file
    > name. However, I cannot use:
    > # mv $(tail -f filenames.txt) archive
    > for example, because tail does not return until it
    > gets a EOF. How can I do it?
    > -Mike


    tail -f filenames.txt | while read filename
    do
    mv "$filename" archive
    done

    --
    Barry Margolin, barmar@alum.mit.edu
    Arlington, MA
    *** PLEASE post questions in newsgroups, not directly to me ***
    *** PLEASE don't copy me on replies, I'll read them in the group ***

  3. Re: tail

    Thanks, that works great.

    Another question: What is a good way to insure
    exclusive execution of a script?

    -Mike


+ Reply to Thread