$ ruby -ne 'BEGIN{s=""};print s if s;s=gsub(/^(.*)$/,"A.\\1 <> B.\\1 or");END{puts s.strip.gsub("or","")+";"}' file
A.AAA <> B.AAA or
A.BBB <> B.BBB or
A.CCC <> B.CCC or
A.DDD <> B.DDD or
A.EEE <> B.EEE or
A.FFF <> B.FFF or
A.GGG <> B.GGG or
A.HHH <> B.HHH ;
Thanks for your inputs.I have executed the command which u suggested.
======================
more test.txt
AAA
BBB
CCC
DDD
EEE
FFF
"test.txt" 7L, 25C written
sl000247:/db2mig/data/back_out $ sed 's/.*/A.& <> B.& or/; $s/ or$/;/' test.txt
A.AAA <> B.AAA or
A.BBB <> B.BBB or
A.CCC <> B.CCC or
A.DDD <> B.DDD or
A.EEE <> B.EEE or
A.FFF <> B.FFF or
A. <> B.;
observe the last 2 lines i have the last line in my input file is FFF
so in the ouput we should get like ..
A.AAA <> B.AAA or
A.BBB <> B.BBB or
A.CCC <> B.CCC or
A.DDD <> B.DDD or
A.EEE <> B.EEE or
A.FFF <> B.FFF ;
---------- Post updated at 02:38 AM ---------- Previous update was at 02:33 AM ----------
Hello kurumi,
i could not able to find out ruby on bash.
ruby -ne 'BEGIN{s=""};print s if s;s=gsub(/^(.*)$/,"A.\\1 <> B.\\1 or");END{puts s.strip.gsub("or","")+";"}' test.txt
-bash: ruby: command not found
Take a look at your data file with `od` or `hexdump` or `vis` or `sed -n l` or `cat -vet` and you'll probably find some character that doesn't show up on your terminal; that's almost certainly the source of the extra line at the end of my sed suggestion's output. Perhaps it's a stray carriage return or other control character?
Also, your sample output in your most recent post differs from that of your original post. The latter has a space before the final semi-colon; the former does not. If you want that space, use this slightly modified version of my original suggestion:
---------- Post updated at 05:43 AM ---------- Previous update was at 02:52 AM ----------
Hello Alister,
I started using our sed in my script.
i have file report3.txt with content
more report3.txt
AAAA
BBBB
CCCC
..
..
XXXX
YYYY
ZZZZ
26 record(s) selected.
when i use our sed command now the results is displazing 2 more lines in the begining and 1 more line extra in the bottom.
A. <> B. or
A. <> B. or
A.-------------------- <> B.-------------------- or
A.AAA <> B.AAA or
..
..
A.ZZZ <> B.ZZZ or
A. <> B. or
A. 26 record(s) selected. <> B. 26 record(s) selected. or
A. <> B. ;
I don't want the lines in red colour should be display in my output .any suggessions how to discard those line while printing?