I want to print complete text between specific words. Here is my requirement.
"123.log" contain below text.
EBSPRODSTART
web logic server
Oracle database administration
Linux operating system
EBSPRODEND
Output should be:-
web logic server
Oracle database administration
Linux operating system
Brief:-
Above word "EBSPROD" is database name. This value will be an input argument. e.g.
$ DBNAME=EBSPROD
$ echo $DBNAME
EBSPROD
$
Am trying like below but it is not printing any value.
$ cat 123.log |sed -n '/^$DBNAMESTART$/,/^$DBANEMEND$/p'
If am passing DBNAME value directly am getting the output as below.
$ cat 123.log |sed -n '/^EBSPRODSTART$/,/^EBSPRODEND$/p'
web logic server
Oracle database administration
Linux operating system
$
Note:- DBNAME will not be same value every time when i execute the script.
There are three problems with your code:
'...'
doesn't interpolate any variables. You need"..."
for that.$DBNAMESTART
looks for a variable calledDBNAMESTART
. You need${DBNAME}START
.DBANEMEND
is not the same asDBNAMEEND
.Thus: