Home Man
Today's Posts

BSD, Linux, and UNIX shell scripting — Post awk, bash, csh, ksh, perl, php, python, sed, sh, shell scripts, and other shell scripting languages questions here.

overwrite specific lines in a file

👤 Login to reply

Thread Tools Search this Thread
# 1  
Old 05-09-2008
overwrite specific lines in a file

Hi all,

I am trying to overwrite some lines of a very big file.
I know the number of the line but I don't know how to point the cursor on its beginning. there is an option to notice the offset in lines?

# 2  
Old 05-09-2008
Are you in an editor?
for vi <esc>20204G takes you to line 20204

Or do you want to replace line #x with text using another tool?
# 3  
Old 05-09-2008
no, I want to do it in a boot script.

I want to do it by commands lines.
# 4  
Old 05-09-2008
For large files sed it's the best tool.
# 5  
Old 05-10-2008
The ed(1) utility is typically used for such tasks.
# 6  
Old 05-10-2008
Ok I have used it, but I think that my manner is not really elegant.

Do you know how to (by sed)...

overwrite a line which actually you only know how it begins but not how finishes?

I want to change a settings file... so I want to do something like that.

sed '49s/HorizSync[...]/HorizSync 30.0 - 83.0/g' xorg.conf

where [...] are characters which I don't know.

Thanks a lot!!
# 7  
Old 05-10-2008
 sed 's/^HorizSync.*/HorizSync 30.0 - 83.0/g' file

👤 Login to reply

« Previous Thread | Next Thread »
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Overwrite specific column in xml file with the specific column from adjacent line rk4k Shell Programming and Scripting 2 10-20-2015 05:00 AM
Create a new file from another file with lines begins with a specific string Litu1988 Shell Programming and Scripting 4 09-01-2014 10:52 AM
Add strings from one file at the end of specific lines in text file gus74 UNIX for Dummies Questions & Answers 3 10-24-2013 05:26 PM
Quick UNIX command to display specific lines in the middle of a file from/to specific word aku UNIX for Dummies Questions & Answers 4 08-12-2013 05:13 AM
awk search/replace specific field, using variables for regexp & subsitution then overwrite file cyphex Shell Programming and Scripting 3 09-23-2012 05:46 AM
Extracting specific lines of data from a file and related lines of data based on a grep value range? Wynner Shell Programming and Scripting 3 05-18-2011 11:35 AM
Substitute specific lines with lines from another file rahmathulla Shell Programming and Scripting 1 01-11-2009 10:45 AM
shell overwrite lines in a file ACTGADE UNIX Desktop Questions & Answers 4 10-28-2008 07:47 AM
how to display specific lines of a specific file raidkridley UNIX for Dummies Questions & Answers 2 10-15-2008 02:46 PM
How do you specific lines in a file? hedgehog001 UNIX for Dummies Questions & Answers 2 08-23-2005 12:04 AM

All times are GMT -4. The time now is 09:36 AM.

Unix & Linux Forums Content Copyright©1993-2018. All Rights Reserved.
Show Password