Sponsored Content
Top Forums Shell Programming and Scripting Replacing System.out.println with Logger.println in *.java using SED (spanned over multiple lines) Post 302684929 by Bhanu Dhulipudi on Friday 10th of August 2012 10:12:31 AM
Old 08-10-2012
MySQL Replacing System.out.println with Logger.println in *.java using SED (spanned over multiple lines)

Hi,

Can anyone help me out for my below problem.

I need to replace all System.out.println with Logger.println in *.java using SED (spanning multiple lines)
including current & sub-directories.

I tried with below command. But it is not replacing when source text is spanned over multiple lines.

Code:
 find -name '*.java' -print -exec sed -i.bak 's/System.*println/Logger.println/g' {} \;

Code:
System.out.println
System . out . println

It is able to replace above two statements. But below statement is not able to.

Code:
System    .
out
. 
println

Also the command needs to be displayed only the list of files which were replaced.

Thanks in advance.

Last edited by Scott; 08-13-2012 at 03:25 AM.. Reason: Code tags
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

replacing multiple lines

i have a file : sample1.txt OBJECT="POINT" ACTION="REDEFINE" POINT_NAME="ABCD001G " GHYT_POPRIORITY_1="1" GHYT_POPRIORITY_2="1" GHYT_POPRIORITY_3="1" GHYT_POPRIORITY_4="1" GHYT_POPRIORITY_USER="1" HIGH_ALARM_PRIORITY_1="1" HIGH_ALARM_PRIORITY_2="1" HIGH_ALARM_PRIORITY_3="1" ... (1 Reply)
Discussion started by: ajnabi
1 Replies

2. Shell Programming and Scripting

replacing multiple lines with single line

Can any one give me the idea on replacing multiple blank lines with a single blank line? Please conside it for a file having more than 100 number of characters. Regards, Siba (3 Replies)
Discussion started by: siba.s.nayak
3 Replies

3. Shell Programming and Scripting

sed: Replacing two lines of text

I just created a file in vi, looks like this: Hello nobody nobody What I need is to have sed change the file so it looks like this: Hello everybody In other words, the sed query needs to look for both instances of "nobody" before it puts the word "everybody" on the first line. ... (2 Replies)
Discussion started by: calrog
2 Replies

4. Shell Programming and Scripting

Awk println

How do you print variables and your own words on the same line ie in bash I would write something like name="Calypso" echo "your name is $Calypso" how does awk differentiate between variables and just plain text ie print "your name is name" ?? Thanks Calypso (2 Replies)
Discussion started by: Calypso
2 Replies

5. UNIX for Dummies Questions & Answers

best method of replacing multiple strings in multiple files - sed or awk? most simple preferred :)

Hi guys, say I have a few files in a directory (58 text files or somthing) each one contains mulitple strings that I wish to replace with other strings so in these 58 files I'm looking for say the following strings: JAM (replace with BUTTER) BREAD (replace with CRACKER) SCOOP (replace... (19 Replies)
Discussion started by: rich@ardz
19 Replies

6. Shell Programming and Scripting

Replacing pattern spanning multiple lines

Hi. I have input like this: <tr> <td class="logo1" rowspan="2"><a href="index.html"><img src="images/logo.png" /></a></td> <td class="pad1" rowspan="2">__</td> <td class="userBox"><img src="images/person.png"/> <a href="http://good.mybook.com/login.jsp">Sign In</a></td> <td... (5 Replies)
Discussion started by: zorrox
5 Replies

7. Shell Programming and Scripting

searching multiple lines and replacing in shell scripting

Hi, I have a file with below contents, ssenthil = rw anilkg = rw I want to search for "ssenthil" and need to delete line 1 and 2 , if the third line starts with "" respectively and blank line immediately and third line starts with " anilkg = rw Please help me . Great day... (5 Replies)
Discussion started by: anil8103
5 Replies

8. Shell Programming and Scripting

Summing over specific lines and replacing the lines with the sum using sed, awk

Hi friends, This is sed & awk type question. I have a text file which has numbers spread all over the file. I want to sum the series of numbers whenever i find it and produce an output file with the sum. For example ###start of input text file #### abc def ghi 1 2 3 4 kjld random... (3 Replies)
Discussion started by: kaaliakahn
3 Replies

9. Shell Programming and Scripting

Bash Scripting Help to automate replacing multiple lines

Background: I am writing a script to help me automate tweaks and things I apply to a custom Android rom I developed. I am on the very last part of my script, and I am stuck trying to find the right command to do what I seek. When I build roms from source, a file called updater-script is... (8 Replies)
Discussion started by: Silverlink34
8 Replies

10. Shell Programming and Scripting

sed parser behaving strange on replacing multiple words in multiple files

I have 4000 files like $cat clus_grp_seq10_g.phy 18 1002 anig_OJJ65951_1 ATGGTTTCGCAGCGTGATAGAGAATTGTTTAGGGATGATATTCGCTCGCGAGGAACGAAGCTCAATGCTGCCGAGCGCGAGAGTCTGCTAAGGCCATATCTGCCAGATCCGTCTGACCTTCCACGCAGGCCACTTCAGCGGCGCAAGAAGGTTCCTCG aver_OOF92921_1 ... (1 Reply)
Discussion started by: sammy777888
1 Replies
Courier::Filter::Logger::File(3pm)			User Contributed Perl Documentation			Courier::Filter::Logger::File(3pm)

NAME
Courier::Filter::Logger::File - File logger for the Courier::Filter framework SYNOPSIS
use Courier::Filter::Logger::File; my $logger = Courier::Filter::Logger::File->new( file_name => $file_name ); # For use in an individual filter module: my $module = Courier::Filter::Module::My->new( ... logger => $logger, ... ); # For use as a global Courier::Filter logger object: my $filter = Courier::Filter->new( ... logger => $logger, ... ); DESCRIPTION
This class is a file logger class for use with Courier::Filter and its filter modules. It is derived from Courier::Filter::Logger::IOHandle. Constructor The following constructor is provided: new(%options): returns Courier::Filter::Logger::File; throws Courier::Error Creates a new logger that logs messages as lines to a file. Opens the file for writing, creating it if necessary. %options is a list of key/value pairs representing any of the following options: file_name Required. The name of the file to which log messages should be written. timestamp A boolean value controlling whether every log message line should be prefixed with a timestamp (in local time, in ISO format). Defaults to false. Instance methods The following instance methods are provided, as inherited from Courier::Filter::Logger::IOHandle: log_error($text): throws Perl exceptions Logs the error message given as $text (a string which may contain newlines). Prefixes each line with a timestamp if the "timestamp" option has been set through the constructor. log_rejected_message($message, $reason): throws Perl exceptions Logs the Courier::Message given as $message as having been rejected due to $reason (a string which may contain newlines). SEE ALSO
Courier::Filter::Logger::IOHandle, Courier::Filter::Logger, Courier::Filter::Overview. For AVAILABILITY, SUPPORT, and LICENSE information, see Courier::Filter::Overview. AUTHOR
Julian Mehnle <julian@mehnle.net> perl v5.14.2 2011-12-27 Courier::Filter::Logger::File(3pm)
All times are GMT -4. The time now is 02:57 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy