reading .prm file


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting reading .prm file
# 1  
Old 07-31-2009
reading .prm file

hi All,

i have a file text_data.prm which contains the below data
-----
[s_m_db2_trn_db2_EVENT_accounting_class]
$$EVENT_START_DATE=2009-07-10 09:08:18

$$DEFAULT_VALUE=''
$$DEFAULT=0
$$CONNECTOR_ID=JDBC06
$$OBJECT_NAME=HSCSP_ACCOUNTING_CLASS
$$OBJECT_VERB=Create
$$EVENT_STATUS=0
$$EVENT_COMMENT=This event is generated from Accounting_class entity
---
i want to read this file using awk command and print a value for $$DEFAULT VARIABLE value.

can any one please help me,
I tried, it is not workinig..
awk NR=4 text_data.prm | cut -f2 -d"="
o/p:
---
2009-07-10 09:08:18

''
0
JDBC06
HSCSP_ACCOUNTING_CLASS
Create
0
This event is generated from Accounting_class entity

but i want o/p as 0.

how to get this result...

Thanks in Advance,
kamal
# 2  
Old 07-31-2009
try..
Code:
-bash-3.2$ awk -F\= '/DEFAULT=/ {print $2}' file
0
-bash-3.2$

# 3  
Old 07-31-2009
hi All,

i have a file text_data.prm which contains the below data
-----
[s_m_db2_trn_db2_EVENT_accounting_class]
$$EVENT_START_DATE=2009-07-10 09:08:18 ^M

$$DEFAULT_VALUE=''^M
$$DEFAULT=0^M
$$CONNECTOR_ID=JDBC06^M
$$OBJECT_NAME=HSCSP_ACCOUNTING_CLASS^M
$$OBJECT_VERB=Create^M
$$EVENT_STATUS=0^M
$$EVENT_COMMENT=This event is generated from Accounting_class entity^M
---

each line ends with the special character ^M

awk -F\= '/DEFAULT=/ {print $2}' file it returns 0 but wen i tried to add 1 to this value it is not adding.
how get value 0 with out special character for $$DEFAULT variable as output.

Thanks in Advance
K.K
# 4  
Old 07-31-2009
Try this:

Code:
awk '/DEFAULT=/{sub("\r","");split($0,a,"=");print a[2]}' file

# 5  
Old 07-31-2009
Code:
awk -F'[=\r]' '$1 == "$$DEFAULT" {print $2}' file

Jean-Pierre.
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

ksh Script, Reading A File, Grepping A File Contents In Another File

So I'm stumped. First... APOLOGIES... my work is offline in an office that has zero internet connectivity, as required by our client. If need be, I could print out my script attempts and retype them here. But on the off chance... here goes. I have a text file (file_source) of terms, each line... (3 Replies)
Discussion started by: Brusimm
3 Replies

2. UNIX for Dummies Questions & Answers

Reading Xml file and print the values into the text file in columnwise?

hi guys, i want help... Reding XML file and print the values into the text file using linux shell script file as per below xml file <sequence> <Filename>aldorzum.doc</Filename> <DivisionCode>US</DivisionCode> <ContentType>Template</ContentType> <ProductCode>VIMZIM</ProductCode> </sequence>... (4 Replies)
Discussion started by: sravanreddy
4 Replies

3. UNIX for Dummies Questions & Answers

Reading XML file and print the values in the text file using Linux shell script

hi guys, i want help... Reding XML file and print the values into the text file using linux shell script file as per below xml file <sequence> <Filename>aldorzum.doc</Filename> <DivisionCode>US</DivisionCode> <ContentType>Template</ContentType> <ProductCode>VIMZIM</ProductCode> </sequence>... (1 Reply)
Discussion started by: sravanreddy
1 Replies

4. Shell Programming and Scripting

Reading UNIX commands from file and redirecting output to a file

Hi All I have written the following script: #!/bin/ksh while read cmdline do echo `$cmdline` pid="$cmdline" done<commands.txt =========== commands.txt contains: ps -ef | grep abc | grep xyz |awk '{print $2}; My objective is to store the o/p of the command in a variable and do... (8 Replies)
Discussion started by: rahulparo
8 Replies

5. Shell Programming and Scripting

fatal: cannot open file `TNAME' for reading (No such file or directory)

Hi, I am running this command through a shell script and getting the error mentioned in the subject line: testing.awk -f x.txt TNAME My testing.awk file contains something like ++++++++++++++++++ #!/usr/bin/awk -f BEGIN{ TAB_NAME="INSERT_ONE_" ARGV ; } if ( $1=="JAM_ONE" &&... (1 Reply)
Discussion started by: kunwar
1 Replies

6. Shell Programming and Scripting

Searching for Log / Bad file and Reading and writing to a flat file

Need to develop a unix shell script for the below requirement and I need your assistance: 1) search for file.log and file.bad file in a directory and read them 2) pull out "Load_Start_Time", "Data_File_Name", "Error_Type" from log file 4) concatinate each row from bad file as... (3 Replies)
Discussion started by: mlpathir
3 Replies

7. UNIX for Advanced & Expert Users

Reading a file and sending mail based on content of the file

Hi Gurus, I am having an requirement. i have to read a list file which contains file names and send mail to different users based on the files in the list file. eg. if file a.txt exists then send a mail to a@a.com simillary for b.txt,c.txt etc. Thanks for your help, Nimu (6 Replies)
Discussion started by: nimu1979
6 Replies

8. Linux

Modifying/Rebuilding non-source PRM?

I can't find a source rpm for a particular tool that I'm trying to modify. I can only get a hold of the noarch and tar.bz2. Can I modify either one of these and re-package them as a noarch.rpm? (2 Replies)
Discussion started by: eur0dad
2 Replies

9. Shell Programming and Scripting

Reading file names from a file and executing the relative file from shell script

Hi How can i dynamically read files names from a list file and execute them from a single shell script. Please help its urgent Thanks in Advance (4 Replies)
Discussion started by: anushilrai
4 Replies
Login or Register to Ask a Question