Reputation: 105
there is one variable var=581 we need to copy the value of this variable at following address(location) and value should appear in front of $$DRM45_RowCount
\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 IMS_FILE_to_LND.par it has data as following
[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
Upvotes: 0
Views: 85
Reputation: 882146
If you just want to replace the value of $$DRM45_RowCount
, you can use awk
as follows:
awk -va=99 '{
if (substr($0,1,17) == "$$DRM45_RowCount=") {
print "$$DRM45_RowCount=" a
} else {
print
}
}'
The -va=99
controls is what will replace the current value (in this case it changes it to 99).
The following test command:
echo '[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' | awk -va=99 '{
if (substr($0,1,17) == "$$DRM45_RowCount=") {
print "$$DRM45_RowCount=" a
} else {
print
}
}'
outputs:
[WCPIT_BIO_EDW.WF:w_DDDMD_LNDG_IMS_NONRET_SALES]
$$Cust_RowCount=72648
$$Sales_RowCount=5235998
$$OuletChangeLog_RowCount=931
$$DRM45_RowCount=99
$$Control_RowCount=4495
$$Outl_Subcat_RowCount=105
$$Fac_Subcat_RowCount=149
Alternatively, you could use sed
:
sed 's/^$$DRM45_RowCount=.*$/$$DRM45_RowCount=99/'
or:
export a=99
sed "s/^\$\$DRM45_RowCount=.*$/\$\$DRM45_RowCount=$a/"
Upvotes: 2