1

I am working on a batch project and at the moment I am having some difficulty with making a batch file put more-then-one/ two lines of data into the txt file, for example, I have tried:

         echo jack.hales>>>options.txt

To attempt to get the text file to have the "jack.hales" on the third line of the txt file.

I am new to batch+txt files so if I am a bit dull on this topic I apologise.

1
  • 1
    You seem to think that the number of > indicates which line to write. Totally wrong. > means overwrite any existing file. >> means to append to any existing file.
    – dbenham
    Jun 19, 2015 at 15:19

2 Answers 2

2

Your question is not very clear but the following will do what you seem to be asking:

echo "line1" > options.txt
echo "line2" >> options.txt
echo "jack.hales" >> options.txt
2
  • What I am trying to do is to be able to specify where I want the text to be inserted, for example I want something on the third line and put 3 ">" 's inbetween the text I want in the file and the filename itself, it will crash the bash, so I was wondering whats happening there, because I am trying to make a config file for a batch program I am making and I am trying to put on a "reset to default" setting, if you were wondering why I was needing this. :) Hope that makes sense.
    – Jack Hales
    Jun 19, 2015 at 14:57
  • Nevermind! Working now I understand what you mean, thanks a bunch! 10/10 @DavilPostill
    – Jack Hales
    Jun 19, 2015 at 15:00
1

Maybe this is easier:

>options.txt (
line1
line2
line-x blabla
)

Not the answer you're looking for? Browse other questions tagged .