With this implementation, an empty line is never a match. Perhaps it should be. In any case, so long as the handling of empty lines is left unspecified, I'm fine with its level of correctness. I'll propose the simplest solution unless there is an explicit requirement demanding something more complicated.
Your sed's results differ from mine (though the sed code itself is posix-compliant). Note: there should be two blank lines at the end of the output, but for some reason the forum's markup is eating them.
Quote:
Originally Posted by rdcwayx
and if you see this situation, what's your expect output?
As I stated in my previous post, the lines are compared in non-overlapping pairs.
---------- Post updated at 11:29 PM ---------- Previous update was at 10:27 PM ----------
Here's a version that compares overlapping pairs of lines (1-2, 2-3, 3-4, etc) and considers a blank line to always be a leading substring of the following line (i.e. blank lines are discarded).
Literally cannot get this one, guys. Single line replacement is simple, but I am not understanding the correct syntax for including a new line feed into the substitution part.
Here's what I got. (Cannot use perl)
#!/bin/sh
set -f
#Start Perms
export HOME=/home/test_user
# End Perms... (6 Replies)
I am trying to find a line in a file ("Replace_Flag") and replace it with a variable which hold a multi lined file.
myVar=`cat myfile`
sed -e 's/Replace_Flag/'$myVar'/' /pathto/test.file
myfile:
cat
dog
boy
girl
mouse
house
test.file:
football
hockey
Replace_Flag
baseball
... (4 Replies)
Hi All,
I have a input file as sample below
<this is not starting of file>
record
line1
line2
line3
end
line4
line5
record
line6
line7
line8
my requirement is this, i want to select a pattern between first record and end, whatever is written between first record and end.
and... (0 Replies)
Hi,
i want to replace
"Hi How
are You when
did you go to
delhi"
to
"Hi How
are you when
did you come from
delhi"
in a file.
Any idea how to do it? (2 Replies)
I have a file example.txt with content look like this:
<TAG>
1
2
3
</TAG>
and I use a sed command to replace everything between <TAG></TAG> as below:
sed -e 's/\(<TAG>\)*\(<.*\)/something/g' example.txt > example.txt.new
But unfortunately, the command failed to replace as i want, it... (23 Replies)
I am new to linux and would like to modify the contents of a file preferably using a one line. The situation is as follows
<start>
some lines
"I am the string"
"replace string"
more lines here
<end>
In the above example,On encountering "I am the string", the "replace string "should be... (6 Replies)
Hi,
I need a sed line that will find all lines that contain "<int key="NSWindowStyleMask">" and then replace the entire line (not just that one string) with "<int key="NSWindowStyleMask">8223</int>". It doesn't necessarily have to use sed as long as it gets the job done :)
Thanks (9 Replies)
the file contains the follwoing lines
/*
* Copyright (C) 1995-1996 by XXX Corporation. This program
* contains proprietary and confidential information. All rights reserved
* except as may be permitted by prior written consent.
*
* $Id: xxx_err.h,v 1.10 2001/07/26 18:48:34 zzzz $
... (1 Reply)