LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux 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!

Notices

Reply
 
Search this Thread
Old 05-16-2008, 01:45 AM   #1
kkpal
Member
 
Registered: Oct 2007
Posts: 101

Rep: Reputation: 15
Thumbs up how to overwrite a particular line of a file


hi all

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

Regards
Komal K Pal
 
Old 05-16-2008, 02:35 AM   #2
colucix
Moderator
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,458

Rep: Reputation: 1941Reputation: 1941Reputation: 1941Reputation: 1941Reputation: 1941Reputation: 1941Reputation: 1941Reputation: 1941Reputation: 1941Reputation: 1941Reputation: 1941
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.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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

BB 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


All times are GMT -5. The time now is 10:44 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
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration