Thread: File writing

    #1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2013
    Posts
    23
    Rep Power
    0

    File writing


    Hello Guys,

    i need a help for writing the content of a file multiple times to another file based upon inputs. for eg:

    file 1:
    xy|input|xyz

    i want to write the content of the file 1 to another file N number of times based on input to for loop as well.

    for eg: for i in {1 ... N}
    write to file 2
    xy|input|xyz
    xy|input|xyz
    ....
    N

    Can any one help me
  2. #2
  3. Contributed User
    Devshed Specialist (4000 - 4499 posts)

    Join Date
    Jun 2005
    Posts
    4,381
    Rep Power
    1871
    A 1-line bash command to show you how to do a for loop.
    $ for((i=0;i<10;i++)); do echo $i ; done


    Can you adapt this to your purpose now?
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2013
    Posts
    23
    Rep Power
    0
    Guys any updates
  6. #4
  7. Contributed User
    Devshed Specialist (4000 - 4499 posts)

    Join Date
    Jun 2005
    Posts
    4,381
    Rep Power
    1871
    Yes, we were all expecting YOU to use the information provided so far (as a hint) in the hope that it would nudge you in the right direction, and inspire you enough to make another attempt at solving the problem for yourself.

    But apparently, it seems you're just after an answer on a plate, and that you're simply not interesting in learning how to solve problems for yourself.

    If you already know how to make a copy of a file, you have all the information you need.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper

IMN logo majestic logo threadwatch logo seochat tools logo