It is necessary to create a shell script or command in unix that can execute the following process (command would be preferred)

on the next path

\\ncsusnasent02.na.jnj.com\its_diq_na_win_dev\PowerCenter\infa_shared\WCPIT_BIO_EDW\SrcFiles\DDDMD\DDD.CLI026.WK0933.DDDMR45.001.head

      

I have one file DDD.CLI026.WK0933.DDDMR45.001.head

if i open this file i get data as following (in one line)

HEADER0101IMS HEALTHDMD Weekly D DD.CLI026.WK0933.DDDMR45 Centocor DMDDRM45 W2009080210120090831125325ssnyder@us.imshealth.com   TRAIL0101 000000000 581 0000000000CKSUM000002236804730

we need to copy 581 (it will not be the same as always, it is updated every day) from this file and update it in the following location

\\ncsusnasent02.na.jnj.com\its_diq_na_win_dev\PowerCenter\infa_shared\WCPIT_BIO_EDW\PrmFiles\LND\IMS_FILE_to_LND.par

      

when i open this file it has the following details

[WCPIT_BIO_EDW.WF:w_DDDMD_LNDG_IMS_NONRET_SALES]
$$Cust_RowCount=72648
$$Sales_RowCount=5235998
$$OuletChangeLog_RowCount=931
**$$DRM45_RowCount=581**
$$Control_RowCount=4495
$$Outl_Subcat_RowCount=105
$$Fac_Subcat_RowCount=149

      

we need to update 581 against $$ DRM45_RowCount

+2


source to share


2 answers


Assuming the title is all on the same line (and the "**" you added just underlines what you want to extract), you can extract the number with:

export num=$(expr 0 + $(cat infile | cut -c137-148))

      

This will extract the number (if your file is correct). The expression "0 + n" separates leading zeros. Then, using my code from your other question:



cat parfile | awk -va=${num} '{
    if (substr($0,1,17) == "$$DRM45_RowCount=") {
        print "$$DRM45_RowCount=" a
    } else {
        print
    }
}' > newparfile

      

newparfile

Should now contain the desired value.

+1


source


You can probably solve this with Windows scripting (I'm not an expert on this), but usually I rather install CygWin and call a bash / awk / sed script for operations like this.Is this acceptable for you and your situation?



0


source







All Articles