Unable to fetch the output using AWK


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Unable to fetch the output using AWK
# 1  
Old 03-12-2010
Unable to fetch the output using AWK

Hi all,

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

Code:
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

3.
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

Addition information on the file format:

Code:
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.

Last edited by pludi; 03-12-2010 at 04:44 AM.. Reason: code tags, please...
# 2  
Old 03-13-2010
Can you explain or elaborate a little bit more on the desired output???
# 3  
Old 03-13-2010
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.
# 4  
Old 03-13-2010
What about:

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

and work on the output with sed from there if you need to adjust it more?
# 5  
Old 03-18-2010
Question


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...
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Unable to fetch BIOS configuration details

Hi All, unable to fetch the bios configuration information and service provider information in centos 5 using dmidecode command. ServiceProvider=`dmidecode -s system-product-name |awk '{print $1}'` BIOS_Configuration=`dmidecode | grep "BIOS Information" -A10 | grep -e... (4 Replies)
Discussion started by: sravani25
4 Replies

2. Shell Programming and Scripting

Unable to redirect output to a file

I m not able to redirect the java version to a file however, it shows as output when I run my script. bash-3.2$ more 1test.tmp java_version=`which java` echo "MY JAVA:"$java_version version=`"$java_version" -version` echo $version >>/tmp/moht/java_version.log $java_version -version 2... (4 Replies)
Discussion started by: mohtashims
4 Replies

3. Shell Programming and Scripting

Fetch the values based on a Key using awk from single file

Hi, Please help to fetch the values for a key from below data format in linux. Sample Input Data Format 11055005|PurchaseCondition|GiftQuantity|1 11055005|PurchaseCondition|MinimumPurchase|400 11055005|GiftCatalogEntryIdentifier|Id|207328014 11429510|PurchaseCondition|GiftQuantity|1... (2 Replies)
Discussion started by: mohanalakshmi
2 Replies

4. Shell Programming and Scripting

awk - fetch multiple data from huge dump

Hello Experts I have a requirement wherein I need to fetch multiple data from huge dump egrep -f Pattern.txt Dump.txt My pattern file has got like 300 entries and Dump file is like 8GB data. It taking eternity to complete on my machine. Is their a faster way to search pattern like using... (5 Replies)
Discussion started by: navkanwal
5 Replies

5. UNIX for Advanced & Expert Users

[Solved] Unable to fetch the UNIX variable information

I am having a file called variable_info.ksh in that file I am having following global variable information like… EMAIL_PATH=/var/mail TMP_PATH=/home/tmp And we are having another temporary parameter file abcd.txt, in that file we are having the following information like… EMAIL|EMAI_PATH I... (4 Replies)
Discussion started by: mesahammad
4 Replies

6. UNIX for Dummies Questions & Answers

Unable to understand ps output.

I m executing ps command and sorting it according to memory usage. Please find the output of the command. # ps aux --sort pmem USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND root 1 0.0 0.0 2060 624 ? Ss 01:54 0:00 init root 2 0.0... (1 Reply)
Discussion started by: pinga123
1 Replies

7. Shell Programming and Scripting

awk fetch numbers after the word

Hi, I would want to fetch all the numbers after a word the number of characters could very. how can I do that? below is the example of the data and the expected output sample data 03 xxxx occurs 1090 times. 04 aslkja occurs 10 times. I would want to fetch 10 & 1090 separately. (13 Replies)
Discussion started by: ahmedwaseem2000
13 Replies

8. Shell Programming and Scripting

How to fetch PIDs from the fuser command output

All, I have to have my script wait for another script when it is being executed. I used fuser -f scriptname to get the PID of the script but when passed the PID to wait command, the command does not accept it as a PID. Below is the example: my.script1: fuser_result=`fuser -f my.script2`... (4 Replies)
Discussion started by: bharath.gct
4 Replies

9. Shell Programming and Scripting

awk getline to fetch output

Input File: CPU minf mjf xcal intr ithr csw icsw migr smtx srw syscl usr sys wt idl 0 37 0 594 2205 1174 123 8 6 36 0 1954 6 8 0 86 1 1 0 49 26 0 44 3 2 6 0 624 2 1 0 97 2 0 0 5 5 0 8 1 0 1 ... (3 Replies)
Discussion started by: bhallarandeep
3 Replies

10. Shell Programming and Scripting

unable to redirect output

I have a script on Linux that is using sfdisk to partition a usb drive. I'm trying to redirectory the standard out and standard error which works, however, there is still messages being diplayed. I guess it's kernel messages? Is there a way to redirect this output? Thanks (5 Replies)
Discussion started by: lochraven
5 Replies
Login or Register to Ask a Question