Hi ,
I need to create a shell script to perform a validation on a file, ihave a file which is ~ seperated.The File contents Looks like below:
HEADER~NFOS-LOH~CIGMA~20051109~124430~ 63893
TRADE_ACTION~TRADE_TYPE~CONTRACT_ID~TRADE_DATE~LOCAL_PRODUCT_TIERA~LOCAL_PRODUCT_TIERB~LOCAL_PRODUCT_TIERC~PUBLISH_DATE_TIME~SOURCE_SYSTEM~ORIGINATING_SYSTEM~SITE_CODE~ENTERED_USER_ID~TRADING_ACRONYM~TRADING_ACRONYM_ISD~TRADING_ACRONYM_TREATS~TRADING_ACRONYM_DESCRIPTION~PRICE~PRIMARY_CURRENCY~PRIMARY_AMOUNT~PRIMARY_SETTLE_DATE~SECONDARY_CURRENCY~SECONDARY_AMOUNT~SECONDARY_SETTLE_DATE~TRADE_STATUS~LAST_MODIFIED_DATE~TRADE_ID~GLOBAL_TRADE_ID~BOOK~BOOK_ENTITY~INTERNAL_BOOK~PREVIOUS_TRADE_ID~ALTERNATE_TRADE_ID~LINKED_TRADE_ID~EVENT_CLASS~TRADE_TYPE_FACTOR~VALUE_ADDED_AMOUNT~VALUE_ADDED_CCY~TRADE_CHANNEL~SALESPERSON_ID~BROKER~INSTRUMENT~BUY_SELL_INDICATOR~VALUE_ADDED_AMOUNT_LOCAL~VALUE_ADDED_CURRENCY_LOCAL~SALES_MARGIN_ON_RATE~WHOLESALE_RATE~CURRENCY_QUOTATIONNEW~~231750~20041013~Spot-Forward~FXFORWARD~FWD~20050610T10:51:01~NFOS~FXALL LOH~LOH~CONVERT~H.TUB GCOREAG~77051~TRING8C~HSBC TUB-GLENCORE AG~1.22966500~USD~99157.11143750~20060203~EUR~80637.50000000~20060203~LIVE~00000000~238445~0003XWD042870213~FWD_EUR_LDN~H.PLC LDN~~0~532092LOH678/2.1.5341879-5-0//~0~~~0.00~USD~FXALL~~~EUR/USD~B~5~GBP~0.0000~1.229665000~USD/EURTRAILER~NFOS-LOH~CIGMA
row in red, header row standard number of ~ would be 5
row in green, column name row standard number of ~ would be 46
row in blue, actual data row standard number of ~ would be 46
The logic i am putting is like standard=count of rows*46-85
actual=count of occurence of each ~ in File
shell script would be like
if
standard = actual then
1
else
0
fi
i am unable to work around with grep & wc command which also includes some calculation as u can see in calculation of standard.
Pls help me out
Thanks in advance
Pls do let me know if you need any more clarification
i am looking for a shell script to solve this particular problem.
Need Logic in creation of shell script
Moderators: chulett, rschirm, roy
-
- Participant
- Posts: 60
- Joined: Tue Jul 12, 2005 3:34 am
-
- Participant
- Posts: 60
- Joined: Tue Jul 12, 2005 3:34 am
Read each record in as a single large varchar. Use the 'count' function to see how many '~' characters are in each record. Use either @INROWNUM or the 'field' command to peel off the first value in each row to know which record type you are processing and how many tildes it should have.
-craig
"You can never have too many knives" -- Logan Nine Fingers
"You can never have too many knives" -- Logan Nine Fingers
-
- Participant
- Posts: 60
- Joined: Tue Jul 12, 2005 3:34 am