Reputation: 1120
I have two parameters:
security.server.port=8443
security.authorization.enabled=true
I want every time to check those parameters in file if one of them missing to add after the next one or opositive or if they missing at all to added after "security.server.ip="
For example:
If we have in the file parameter:
security.authorization.enabled=true
Expected View:
security.server.port=8443
security.authorization.enabled=true
Not able to create whole process grep and add after the grep
Upvotes: 0
Views: 61
Reputation: 204074
Something like this might be what you're looking for:
awk '
BEGIN{
params["security.server.port=8443"]
params["security.authorization.enabled=true"]
}
{
for (param in params)
if ($0 == param)
params[param] = 1
print
}
END {
for (param in params)
if (params[param] != 1)
print param
}
' file
It's hard to say without more representative input and expected output.
Upvotes: 2