Article 520PZ New line separator for each grep result (Even if grep outupt is null)

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:
echo -n "Host is:"; grep -h -E 'host_value' /file_path
echo -n "IPAD is:"; grep -h -E 'Address_value' /file_path
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 parameterlatest?d=yIl2AUoC8zA latest?i=76qZiwOv5aQ:2JEDGPiLvpU:F7zBnMy latest?i=76qZiwOv5aQ:2JEDGPiLvpU:V_sGLiP latest?d=qj6IDK7rITs latest?i=76qZiwOv5aQ:2JEDGPiLvpU:gIN9vFw76qZiwOv5aQ
External Content
Source RSS or Atom Feed
Feed Location https://feeds.feedburner.com/linuxquestions/latest
Feed Title LinuxQuestions.org
Feed Link https://www.linuxquestions.org/questions/
Reply 0 comments