bash script - Unix

This is a discussion on bash script - Unix ; Hi, I am trying to write a bash script, which would delete the 'first' line from a txt file and execute a command. This procedure goes in a loop, until the file has no more content. Eg. If txt file ...

+ Reply to Thread
Results 1 to 3 of 3

Thread: bash script

  1. bash script

    Hi,

    I am trying to write a bash script, which would delete the 'first'
    line from a txt file and execute a command. This procedure goes in a
    loop, until the file has no more content.

    Eg.

    If txt file contains 1 2 3 as input... Below, would be the likely way
    for execution


    1
    2
    3
    cmd
    2
    3
    cmd
    3
    cmd


  2. Re: bash script

    On 18 May 2007 09:30:20 -0700, msnsachin@gmail.com wrote:
    > Hi,
    >
    > I am trying to write a bash script, which would delete the 'first'
    > line from a txt file and execute a command. This procedure goes in a
    > loop, until the file has no more content.


    Hmm, what if the command fails, do you put the line back in the txt file?

    Sounds like a wonderful homework exercise.

    This may help with your "while read" loop and whatnot.
    http://tldp.org/LDP/abs/html/index.html

    Then there is
    http://www.catb.org/~esr/faqs/smart-questions.html

    and do bookmark this very large, Frequently Asked Questions (faq) search engine
    http://groups.google.com/advanced_group_search
    key words(s) in the first box
    *linux* in Newsgroup box. You need to use the two
    asterisks around linux, pick English


  3. Re: bash script

    On 2007-05-18, msnsachin@gmail.com wrote:
    > Hi,
    >
    > I am trying to write a bash script, which would delete the 'first'
    > line from a txt file and execute a command. This procedure goes in a
    > loop, until the file has no more content.


    while IFS= read -r line
    do
    : do whatever
    done < FILE

    > Eg.
    >
    > If txt file contains 1 2 3 as input... Below, would be the likely way
    > for execution
    >
    >
    > 1
    > 2
    > 3
    > cmd
    > 2
    > 3
    > cmd
    > 3
    > cmd
    >



    --
    Chris F.A. Johnson, author |
    Shell Scripting Recipes: | My code in this post, if any,
    A Problem-Solution Approach | is released under the
    2005, Apress | GNU General Public Licence

+ Reply to Thread