Sponsored Content
Full Discussion: Replace entire line
Top Forums Shell Programming and Scripting Replace entire line Post 302351286 by shantanuo on Tuesday 8th of September 2009 03:21:32 AM
Old 09-08-2009
Replace entire line

I want to replace one line from my configuration file with the new settings.
The file Name: /etc/httpd/conf/httpd.conf

The following line should be replaced with the line mentioned below.
Code:
LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined
LogFormat "\"%h\" \"%l\" \"%u\" \"%t\" \"%r\" \"%>s\" \"%b\" \"%{Referer}i\" \"%{User-Agent}i\"" combined

I want to accomplish this task using sed and I do not want to use vi

Last edited by shantanuo; 09-08-2009 at 04:32 AM.. Reason: Additional info
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Perl Search and replace entire line

I have a perl function in my script that needs to replace an entire line in a file sub changestate { my $base = (); my @base = (); open(BASE, $file) || die("Could not open file!"); @base=<BASE>; close (BASE); foreach $base(@base) { if($base =~... (1 Reply)
Discussion started by: insania
1 Replies

2. Shell Programming and Scripting

Replace Entire line if any part matches regexp

Hey guys, I have a file that I've slowly been awking, seding, and greping for data entry. I am down to pull the addresses out to insert them into an excel file. Each address is a few lines, but i want to put a semicolon delimiter in between each address so I can export the text file into excel and... (6 Replies)
Discussion started by: Cocoabean
6 Replies

3. Shell Programming and Scripting

Print the entire line if second field has value P

Friends, I have .txt file with 3 millions of rows. File1.txt ABC1|A|ABCD1|XYZ1 ABC2|P|ABCD2|XYZ2 ABC3|A|ABCD3|XYZ3 ABC4|P|ABCD4|XYZ4 If second field has value P then print the entire line. Thanks in advance for your help, Prashant (4 Replies)
Discussion started by: ppat7046
4 Replies

4. UNIX for Advanced & Expert Users

command to replace the entire line from the key point

Hi everyone I am new to Unix. I got stuck up by small issue. I have text file something like this abc 'xyz' '5' lmn 'pqr' '7' i want to replace the abc 'xyz' '5' to abc 'xyz' '6' but i have a key as 'xyz' based on this key i want to do that. I am not aware of how to use sed... (7 Replies)
Discussion started by: Vijayaragavan
7 Replies

5. Shell Programming and Scripting

grep to find entire line ....

As per my understanding below mentioned line of code finding a word 'boy' in $ACULOG... num_errors=`grep -i -e fail -e illegal -e exception -e "<E" -e boy $ACULOG | wc -l` if I'm not corerct, please correct me. How I can find entire line like "This is a boy" with something similar as above... (1 Reply)
Discussion started by: heyitsmeok
1 Replies

6. UNIX for Dummies Questions & Answers

Show the entire line using ps

Using the vanilla ps -ef I noticed that the CMD (or command) line gets cut off after 90 characters UID PID PPID C STIME TTY TIME CMD root 6020 3822 0 Jun 19 ? 0:01 ./webservd-wdog -r /export/opt/sows/61sp4 -d /export/opt/sows/61sp4/https-logse Googling... (4 Replies)
Discussion started by: SixSigma1978
4 Replies

7. Shell Programming and Scripting

Replace character in files of entire folder? sed? or what?

Hello, I do have several files in one folder each file contains measurement data. for each file I would like to replace the character "," by "." ? How can I do this and how can I do this for each file at once? E.G. data_1.dat, data_x.dat (original version) data_1out.dat, data_x_out.dat... (10 Replies)
Discussion started by: rollinator
10 Replies

8. Shell Programming and Scripting

Help with sed to replace entire line

Hi, I need to replace an entire mailx line as follows using sed: sed -e 's/<line1>/<newline>/g' <filename> But I am getting comman garbled error since the new line has many special characters. I enclosed allspecial chars in \ but still no use. Can any one help me? Please use code... (2 Replies)
Discussion started by: vinodhin4
2 Replies

9. Shell Programming and Scripting

Using the entire line with space in between

Hi Folks, I have a report data like the one seen below. FRUITS@NEW_ORANGE(1500 04/29) FRUITS@NEW_ORANGE(1500 05/04) FRUITS@NEW_ORANGE(1500 05/05) FRUITS@NEW_ORANGE(1500 05/07) FRUITS@NEW_ORANGE(1500 05/12) I need to use each of this lines separately in another for loop like the one... (2 Replies)
Discussion started by: jayadanabalan
2 Replies

10. Shell Programming and Scripting

How to extract entire para instead of just line?

Hello, I have a file with multiple paragraphs/sections each starting with word "Handle" and if I grep for a pattern, I should get contents of entire section/para (not just line). Please advise, thanks! #script.sh file.txt "System Information" Handle 0x0001 DMI type 1, 27 bytes. ... (9 Replies)
Discussion started by: reddyr
9 Replies
Agent::Driver::Fork(3pm)				User Contributed Perl Documentation				  Agent::Driver::Fork(3pm)

NAME
Log::Agent::Driver::Fork - dummy driver for forking output to multiple drivers SYNOPSIS
use Log::Agent; require Log::Agent::Driver::Fork; require Log::Agent::Driver::Foo; require Log::Agent::Driver::Bar; my $driver = Log::Agent::Driver::Fork->make( Log::Agent::Driver::Foo->make( ... ), Log::Agent::Driver::Bar->make( ... ) ); logconfig(-driver => $driver); DESCRIPTION
This driver merely acts a multiplexer for logxxx() calls, duplicating them and distributing them to other drivers. The only routine of interest here is the creation routine: make(@drivers) Create a Log::Agent::Driver::Fork driver that duplicates logxxx() calls and distributes them to the drivers in @drivers. The arguments must be the return value of the make() call for the client drivers. NOTES
Many thanks go to Daniel Lundin and Jason May who proposed this module independently. Eventually, logconfig() will support multiple drivers directly. But, for now, this solution requires no change to the existing interface. AUTHOR
Mark Rogaski <mrogaski@pobox.com> LICENSE
Copyright (C) 2002 Mark Rogaski; all rights reserved. See Log::Agent(3) or the README file included with the distribution for license information. SEE ALSO
Log::Agent::Driver(3), Log::Agent(3). perl v5.10.0 2009-07-23 Agent::Driver::Fork(3pm)
All times are GMT -4. The time now is 01:13 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy