Unable to fetch the output using AWK

Hi all,

From the below file I need to fetch the data in the below output format.

ToolInstanceID "diw_dm_sales"
Identifier "Sales_source_load"
Promt			Default 	ParamType  	ParamLength  	ParamScale
"Database_Name"	"ORCL"	 	"0" 		"0"		"0"
Identifier "retail_source_load"
Promt			Default 	ParamType  	ParamLength  	ParamScale
"Database_Name"	"ORCL"	 	"0" 		"0"		"0"

I have tried using the few commands, but I am unable to fetch the information.

  1. grep ToolInstanceID file_name

  2. awk '/BEGIN DSJOB/{getline;print}' file_name

#! /bin/bash
dnsfilter() {
awk '/BEGIN DSSUBRECORD/{c=3;next}c-->'"$1" "$2"| awk '/END DSSUBRECORD/{exit}{print}' |awk '/Owner/{exit}{print}' |
awk '{n2=n1;n1=n;n=$0;if(NR%3==0){printf"%s,%s,%s\n",n2,n1,n}}'
}
a=0
cnt=2
a1="file_name"
while [ $a -ne $cnt ]
do
  printf " "
  dnsfilter $a $a1
echo " dnsfilter $a $a1                      "
echo "                       "
echo "                       "
 a=$(( $a + 1 ))
done  >77.txt 2>77.err

Addition information on the file format:

BEGIN HEADER
   CharacterSet "ENGLISH"
   ToolInstanceID "diw_dm_sales"
   MDISVersion "1.0"
END HEADER
BEGIN DSJOB
   Identifier "Sales_source_load"
   DateModified "2010-01-01"
   	BEGIN DSRECORD
      		Identifier "ROOT"
      		OLEType "CJobDefn"
      		Readonly "0"
     		Name "Sales_source_load"
      		NextID "79"
      		Container "V0"
      		JobVersion "2.0.0"
      		BeforeSubr "DB_Params\\#params#"
      		ControlAfterSubr "0"
      		Parameters "CParameters"
      			BEGIN DSSUBRECORD
         			Name "Enter the database name"
        			Prompt "Database_Name"
				Default "ORCL"
         			ParamType "0"
         			ParamLength "0"
         			ParamScale "0"
      			END DSSUBRECORD
      			BEGIN DSSUBRECORD
         			Name "Enter user name"
         			Prompt "User_name"
				Default "SCOTT"
         			ParamType "0"
         			ParamLength "0"
         			ParamScale "0"
      			END DSSUBRECORD
	END DSRECORD
	BEGIN DSRECORD
      		Identifier "V0S188"
      		OLEType "CCustomStage"
      		Readonly "0"
      		Name "Copy_DIP"
      		NextID "5"
      		InputPins "V0S188P1"
      		OutputPins "V0S188P3|V0S188P4"
      		StageType "PxCopy"
      		AllowColumnMapping "0"
      		Properties "CCustomProperty"
      			BEGIN DSSUBRECORD
         			Name "force"
         			Value " "
      			END DSSUBRECORD
	END DSRECORD
END DSJOB


#################################################################
################# Second job    ##############
#################################################################

BEGIN DSJOB
   Identifier "retail_source_load"
   DateModified "2010-01-01"
   	BEGIN DSRECORD
      		Identifier "ROOT"
      		OLEType "CJobDefn"
      		Readonly "0"
     		Name "retail_source_load"
      		NextID "79"
      		Container "V0"
      		JobVersion "2.0.0"
      		BeforeSubr "DB_Params\\#params#"
      		ControlAfterSubr "0"
      		Parameters "CParameters"
      			BEGIN DSSUBRECORD
         			Name "Enter the database name"
        			Prompt "Database_Name"
				Default "ORCL"
         			ParamType "0"
         			ParamLength "0"
         			ParamScale "0"
      			END DSSUBRECORD
      			BEGIN DSSUBRECORD
         			Name "Enter user name"
         			Prompt "User_name"
				Default "SCOTT"
         			ParamType "0"
         			ParamLength "0"
         			ParamScale "0"
      			END DSSUBRECORD
	END DSRECORD
	BEGIN DSRECORD
      		Identifier "V0S188"
      		OLEType "CCustomStage"
      		Readonly "0"
      		Name "Copy_DIP"
      		NextID "5"
      		InputPins "V0S188P1"
      		OutputPins "V0S188P3|V0S188P4"
      		StageType "PxCopy"
      		AllowColumnMapping "0"
      		Properties "CCustomProperty"
      			BEGIN DSSUBRECORD
         			Name "force"
         			Value " "
      			END DSSUBRECORD
	END DSRECORD
END DSJOB

Any help would be greatly appreciated.

Regards,
Suri.

Can you explain or elaborate a little bit more on the desired output???

Looks like the OP wants to extract certain named pairs of a jcl on the same line while selectively extracting others in a stacked format so they present in a tabular format within the output file. Heavy-ish lifting for such little code provided by the OP.

Might make more sense if there were some code or a sense of work already done from the OP.

---------- Post updated at 07:48 ---------- Previous update was at 07:48 ----------

Looks like the OP wants to extract certain named pairs of a jcl on the same line while selectively extracting others in a stacked format so they present in a tabular format within the output file. Heavy-ish lifting for such little code provided by the OP.

Might make more sense if there were some code or a sense of work already done from the OP.

What about:

egrep "ToolInstanceID|Identifier|Database_Name|Promt" file.txt

and work on the output with sed from there if you need to adjust it more?

I am unable to fetch proper output for the below file using below code
Code:
#! /bin/bash
dnsfilter() {
awk '/BEGIN DSSUBRECORD/{c=3;next}c-->'"$1" "$2"| awk '/END DSSUBRECORD/{exit}{print}' |awk '/Owner/{exit}{print}' |
awk '{n2=n1;n1=n;n=$0;if(NR%3==0){printf"%s,%s,%s\n",n2,n1,n}}'
}
a=0
cnt=2
a1="file_name"
while [ $a -ne $cnt ]
do
printf " "
dnsfilter $a $a1
echo " dnsfilter $a $a1 "
echo " "
echo " "
a=$(( $a + 1 ))
done >77.txt 2>77.err

Output should get in the below output format. But i am unable to get this. Any help on this greatly appreciated.

Promt Default ParamType ParamLength ParamScale
"Database_Name" "ORCL" "0" "0" "0"
"Enter user name" "User_name" "SCOTT" "0" "0" "0"

Promt Default ParamType ParamLength ParamScale
"Database_Name" "ORCL" "0" "0" "0"
"Enter user name" "User_name" "SCOTT" "0" "0" "0"

---------- Post updated at 04:40 AM ---------- Previous update was at 04:37 AM ----------

FYI...