Computing.Net > Forums > Programming > echo text to specific line in file

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

echo text to specific line in file

Reply to Message Icon

Name: remda
Date: January 11, 2005 at 13:10:05 Pacific
OS: winxp command promt
CPU/Ram: 512
Comment:

Hi !
I Im trying to add some text to a txt file like this:
echo blablabla >>mu.txt
But I dont want the text to be added in the beginning of the file. I want to add the text to a specific line in the txt file..how can I do that?

Thanks



Sponsored Link
Ads by Google

Response Number 1
Name: dtech10
Date: January 11, 2005 at 13:15:50 Pacific
Reply:

Hi
Do you want to add a new line of text between the existing lines and at a certain line number or what.
Will the text contain "<" or ">" as this may cause some problems.


0

Response Number 2
Name: remda
Date: January 11, 2005 at 13:24:12 Pacific
Reply:

Hi

What im trying to do is adding text to a txt file using the echo command in the dos promt.
For example, if the txt file contain this text:
hiui
d
gigi
<-- on this line I want to add some text
didi
oo
aaa

Is it possible using echo in cmd?



0

Response Number 3
Name: dtech10
Date: January 11, 2005 at 13:37:13 Pacific
Reply:

Hi
It's not possible from a command line
you are only able to create a new file or append to an existing one.
ie echo "text" > File (New File created)
echo "Text" >> File (Append to existing File")

What you need is a batch file, do you need to add the line at the same line number every time or doe's this change.



0

Response Number 4
Name: remda
Date: January 11, 2005 at 13:46:34 Pacific
Reply:

ok, thanks for the info.. I just wanted to know if it was possible.
I think that there would be no use to create a batch file as I am limited to use cmd with parameters.. like this:
cmd.exe /k echo "text" >>File


0

Response Number 5
Name: remda
Date: January 11, 2005 at 13:50:01 Pacific
Reply:

The line would be at the same line number every time yes.


0

Related Posts

See More



Response Number 6
Name: dtech10
Date: January 11, 2005 at 15:36:22 Pacific
Reply:

Hi
will the text be just one word or more and do you require the quotes.
What will the line number be.



0

Sponsored Link
Ads by Google
Reply to Message Icon






Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Programming Forum Home


Sponsored links

Ads by Google


Results for: echo text to specific line in file

Reading Specific Lines in C++ www.computing.net/answers/programming/reading-specific-lines-in-c/2843.html

Sed:Add text to end of line in file www.computing.net/answers/programming/sedadd-text-to-end-of-line-in-file/15109.html

batch edit specific line in txt www.computing.net/answers/programming/batch-edit-specific-line-in-txt/16778.html