Home
Man
Search
Today's Posts
Register

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

Tags
file, lines, shell scripts, specific

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?

thanks!
# 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
Code:
 sed 's/^HorizSync.*/HorizSync 30.0 - 83.0/g' file

Regards
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 06: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 11:52 AM
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 06:13 AM
awk search/replace specific field, using variables for regexp & subsitution then overwrite file cyphex Shell Programming and Scripting 3 09-23-2012 06: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 12:35 PM
Substitute specific lines with lines from another file rahmathulla Shell Programming and Scripting 1 01-11-2009 11:45 AM
shell overwrite lines in a file ACTGADE UNIX Desktop Questions & Answers 4 10-28-2008 08:47 AM
how to display specific lines of a specific file raidkridley UNIX for Dummies Questions & Answers 2 10-15-2008 03:46 PM
How to read specific lines in a bulk file using C file Programming rajan_ka1 Programming 10 11-10-2005 03:29 AM
How do you specific lines in a file? hedgehog001 UNIX for Dummies Questions & Answers 2 08-23-2005 01:04 AM


All times are GMT -4. The time now is 10:50 PM.

Unix & Linux Forums Content Copyright 1993-2018. All Rights Reserved.
UNIX.COM Login
Username:
Password:  
Show Password