# client id: 298
298 local:/opt/intrd298.psv: norm /opt/hold OURTXNS nocr schema@schema
298 local:/opt/incpn298.psv: norm /opt/hold OURTXNS nocr schema@schema
298 local:/opt/inbtb298.psv: norm /opt/hold OURTXNS nocr schema@schema
298 local:/opt/inbal298.psv: norm /opt/hold OURBLS nocr schema@schema
298 local:/opt/inftbb298.psv: norm /opt/hold FTBBCKS nocr schema@schema
298 local:/opt/inftbf298.psv: norm /opt/hold FTBFRONTS nocr schema@schema
298 local:/opt/inmgl298.psv: norm /opt/hold OURTXNS nocr schema@schema
298 local:/opt/inpos298.psv: norm /opt/hold OURPOS nocr schema@schema
# client id: 299
299 local:/opt/intrd299.psv: norm /opt/hold OURTXNS nocr schema@schema
299 local:/opt/incpn299.psv: norm /opt/hold OURTXNS nocr schema@schema
299 local:/opt/inbtb299.psv: norm /opt/hold OURTXNS nocr schema@schema
299 local:/opt/inbal299.psv: norm /opt/hold OURBLS nocr schema@schema
299 local:/opt/inftbb299.psv: norm /opt/hold FTBBCKS nocr schema@schema
299 local:/opt/inftbf299.psv: norm /opt/hold FTBFRONTS nocr schema@schema
299 local:/opt/inmgl299.psv: norm /opt/hold OURTXNS nocr schema@schema
299 local:/opt/inpos299.psv: norm /opt/hold OURPOS nocr schema@schema
I need to have eight entries for each client in the above file. I am checking for the number of entries using this line of code
if [ `grep "^$client " $F | wc -l | sed "s/ //g"` != 8 ]
then
echo "not 8 entries for ID $client found!"
fi
fi
But if any entry is missing I want create and append that to the existing entries for that client. If the client doesn't have entry at all I want to create all the 8 entries and append that at the end of the file using shell script. Please advise
Start Free Trial