Computing.Net > Forums > Linux > Replacing a line in a text file

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Click here to start participating now! Also, check out the New User Guide.

Replacing a line in a text file

Reply to Message Icon

Name: Preethi123
Date: March 19, 2009 at 00:50:24 Pacific
OS: Linux
Subcategory: Software Problems
Comment:

i have a text file which has got 2 lines and i need to replace the first line with someother line. i tried using sed, but in vain as there is a catch inthe text file from where am reading the text. The second line just ends up there without a trailing line. And if at all i use sed, it is not working. Any help on this would be appreciated



Sponsored Link
Ads by Google

Response Number 1
Name: nails
Date: March 19, 2009 at 09:31:25 Pacific
Reply:


I'm not understanding this statement:

>>The second line just ends up there without a trailing line.

Could it be the last line doesn't have a terminating Line Feed?

If that's the case, try this:

echo "" > yourtestfile

and then try your sed command.


0

Response Number 2
Name: ghostdog
Date: March 24, 2009 at 04:30:39 Pacific
Reply:

show a sample input file. and describe properly what you want to see as output


0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More


Which version of Linux? Nvidia Drivers -Sabayon 4...



Post Locked

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


Go to Linux Forum Home


Sponsored links

Ads by Google


Results for: Replacing a line in a text file

Variable access in text file. www.computing.net/answers/linux/variable-access-in-text-file/14082.html

What the grep am I doing wrong? www.computing.net/answers/linux/what-the-grep-am-i-doing-wrong/3054.html

Premature end of the script header www.computing.net/answers/linux/premature-end-of-the-script-header/2858.html