LinuxQuestions.org
Go Job Hunting at the LQ Job Marketplace

Welcome to LinuxQuestions.org, a friendly and active Linux Community.

You are currently viewing LQ as a guest. By joining our community you will have access to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!

Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.

Are you new to LinuxQuestions.org? Visit the following links:
Site Howto | Site FAQ | Sitemap | Register Now

If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.

Go Back   LinuxQuestions.org > Forums > Linux > Linux - Newbie
User Name
Password
Linux - Newbie This forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Reply
 
Thread Tools
Old 05-16-2008, 01:45 AM   #1
kkpal
Member
 
Registered: Oct 2007
Posts: 79
Thumbs up how to overwrite a particular line of a file


[Log in to get rid of this advertisement]
hi all

what is command for overwriting a particular line (number 113) of a text file using Bash script.

Regards
Komal K Pal
kkpal is offline     Reply With Quote
Old 05-16-2008, 02:35 AM   #2
colucix
Senior Member
 
Registered: Sep 2003
Location: Bologna, Italia
Distribution: OpenSUSE 11.0
Posts: 2,276
You can try sed specifying the line number and substituting any sequence of characters with the new text:
Code:
sed 113s/.*/new text here/ file
if you want to edit file in place, use the -i option, but before doing this, test the results or make a backup copy of the original file.
colucix is offline     Reply With Quote

Reply

Submit thread to Digg | Submit thread to del.icio.us | Submit to LQ Bookmarks

« Back to Top »

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
How to overwrite a complete File system? gochita Linux - General 8 02-02-2007 06:56 PM
php - Read file line by line and change a specific line. anrea Programming 2 01-28-2007 01:43 PM
can we overwrite the permissions of folder/file zameer_india Linux - Networking 0 09-30-2004 01:11 AM
Proftpd file overwrite problem NetScripter Linux - Software 6 10-14-2003 01:15 AM



Add LQ To Your Yahoo Add LQ To Your Google Add LQ To Your MSN Add LQ To Your Blog
All times are GMT -5. The time now is 10:15 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
RSS2  LQ Podcast
RSS2  LQ Radio
Open Source Consulting | Domain Registration