New line separator for each grep result (Even if grep outupt is null)
by eng_mohammedmostafa from LinuxQuestions.org on (#520PZ)
If file content is:
Quote:
How to force each grep output to be in a separate line even if the grep output is null? And how to replace null values with specific string such as 'No value for this parameter'.
For example, if the host_value is hostname but Address_value is null then output should be as below:
Host is:hostname
IPAD is:No value for this parameter


Quote:
echo -n "Host is:"; grep -h -E 'host_value' /file_path echo -n "IPAD is:"; grep -h -E 'Address_value' /file_path |
For example, if the host_value is hostname but Address_value is null then output should be as below:
Host is:hostname
IPAD is:No value for this parameter