Sponsored Content
Top Forums Shell Programming and Scripting Inserting text into a file but searching for the place to put it! Post 302456497 by quirkasaurus on Friday 24th of September 2010 11:18:05 AM
Old 09-24-2010
Code:
vi '+/192\.189\.1\.2' log_file << EOF
o$fwInsert^[:wq
EOF

where the ^[ is the ESC character, entered by typing CONTROL-V ESCAPE in vi insert mode.

Also. It may be tricky to add the backslashes between the IP numbers...
So, you could probably get away without using them... But the dot is a RE token.

maybe this might be a tad better:

Code:
vi +/" 192.189.1.2$" log_file << EOF
...

... or...

Code:
vi +/" $IP$" log_file << EOF
...


Last edited by quirkasaurus; 09-24-2010 at 12:20 PM.. Reason: mistake on IP address.
This User Gave Thanks to quirkasaurus For This Post:
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

place to put statup scripts?

I have written a script to start websphere server, I dont know where to put the file in the OS . please put me the place to put the starup scripts in linux, solaris and AIX? (2 Replies)
Discussion started by: jayaramanit
2 Replies

2. Shell Programming and Scripting

Perl - Enter text in a file in a place.

Hi, I have a simple question: I need to enter some text in a text file at a certain place via perl. I would first need to find that specific text in the file and then I would like to insert a line after that particular line. Say I have this text file: I am a great Perl Programmer I... (1 Reply)
Discussion started by: som.nitk
1 Replies

3. Shell Programming and Scripting

Inserting text and modifying the file

I am in a dire need of doing this job , please help from shell script or perl script. It will be highly appreciated. Please have a look at the following INPUT file; The first 14 rows are not of interest but I want them to be included in the output file as they are. From the row 14... (3 Replies)
Discussion started by: digipak
3 Replies

4. Shell Programming and Scripting

inserting a string to a text file

Hello Can somebody please help me with the following script? I'm trying to create a text file with 20 blank lines and then insert a string in line 2 but nothing is printed in the itxtfile. I can create the file with 20 blank lines but when I "tell" it to print something on the second line, it... (4 Replies)
Discussion started by: goude
4 Replies

5. Shell Programming and Scripting

script for inserting line at specific place in file

I use zentyal for my server admin, which is great but zentyal auto-generates config file on boot and hence overwrites any changes made directly to config files. In order to allow multiple user access to a MS ACCESS database, I need to customise the smb.conf file and add the following line to the... (9 Replies)
Discussion started by: barrydocks
9 Replies

6. UNIX for Dummies Questions & Answers

Inserting a column into a text file

I have a tab delimited text file with multiple columns (data.txt). I would like to insert a column into the text file. The column I want to insert is in a text file (column.txt). I want to insert it into the 5th column of data.txt. How do I go about doing that? Thanks! (2 Replies)
Discussion started by: evelibertine
2 Replies

7. Shell Programming and Scripting

searching a file with a specified text without using conventional file searching commands

without using conventional file searching commands like find etc, is it possible to locate a file if i just know that the file that i'm searching for contains a particular text like "Hello world" or something? (5 Replies)
Discussion started by: arindamlive
5 Replies

8. Shell Programming and Scripting

Inserting text into a new file

Hi all, I want to create a file and then insert some text into it. I'm trying to create a .sh script that will create a new python file from a template. Can someone tell me why this won't work, touch $1 | sed -e '1i\Some test code here' Sorry I'm quite new to all this! Just as a side... (3 Replies)
Discussion started by: ahodgson
3 Replies

9. Shell Programming and Scripting

Help with sed and inserting text from another file

I need to insert text from one file into another file after specific term. I guess sed is the best method of doing this and I can insert a specified text string using this script but I am not sure how to modify it to insert text from another file: #!/bin/sh sed 's/\<VirtualHost... (17 Replies)
Discussion started by: barrydocks
17 Replies

10. Shell Programming and Scripting

Cut text file in place

I have a file that i want to take only the first part of it and discard the rest, to be accurate,I need the first 137097 lines but I cant use split because I dont have enough space on my disck. I need sth to cut the file in its place (3 Replies)
Discussion started by: Heidi Heweidy
3 Replies
Net::Server::Log::Log::Log4perl(3)			User Contributed Perl Documentation			Net::Server::Log::Log::Log4perl(3)

NAME
Net::Server::Log::Log::Log4perl - log via Log4perl SYNOPSIS
use base qw(Net::Server::PreFork); __PACKAGE__->run( log_file => 'Log::Log4perl', log4perl_conf => '/path/to/my/log4perl.conf', log4perl_logger => 'myapp', ); DESCRIPTION
This module provides Log::Log4perl style logging to the Net::Server system. CONFIGURATION
log_file To begin using Log::Log4perl logging, simply set the Net::Server log_file configuration parameter to "Log::Log4perl". If the magic name "Log::Log4perl" is used, all logging will be directed to the Log4perl system. If used, the "log4perl_conf", "log4perl_poll", "log4perl_logger" may also be defined. log4perl_conf Only available if "log_file" is equal to "Log::Log4perl". This is the filename of the log4perl configuration file - see Log::Log4perl. If this is not set, will die on startup. If the file is not readable, will die. log4perl_poll If set to a value, will initialise with Log::Log4perl::init_and_watch with this polling value. This can also be the string "HUP" to re- read the log4perl_conf when a HUP signal is received. If set to 0, no polling is done. See Log::Log4perl for more details. log4perl_logger This is the facility name. Defaults to "Net::Server". DEFAULT ARGUMENTS FOR Net::Server The following arguments are available in the default "Net::Server" or "Net::Server::Single" modules. (Other personalities may use additional parameters and may optionally not use parameters from the base class.) Key Value Default ## log4perl parameters (if log_file eq Log::Log4perl) log4perl_conf "filename" will die if not set log4perl_poll number or HUP 0 (no polling) log4perl_logger "name" "Net::Server" METHODS
"initialize" This method is called during the initilize_logging method of Net::Server. It returns a single code ref that will be stored under the log_function property of the Net::Server object. That code ref takes log_level and message as arguments and calls the initialized log4perl system. LICENCE
Distributed under the same terms as Net::Server POD ERRORS
Hey! The above document had some coding errors, which are explained below: Around line 84: You forgot a '=back' before '=head1' Around line 93: '=item' outside of any '=over' Around line 129: Unknown directive: =over4 Around line 131: '=item' outside of any '=over' perl v5.16.2 2012-06-05 Net::Server::Log::Log::Log4perl(3)
All times are GMT -4. The time now is 07:41 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy