Is there a way using awk to print text if a certain condition is met? For example, print the Hostname line and subsequent lines until you see the next line beginning with Hostname. Do not print the Hostname line if the next line begins with Hostname or a blank line. Output file contains:
Hostname: server1.am.acme1.com
account1 Jane Doe
account2 Joe Smith
Hostname: server2.am.acme1.com
Hostname: server3.am.acme1.com
Hostname: server4.am.acme1.com
account1 Jalen Tulip
account2 LeBron Jim
Hostname: server5.am.acme1.com
Hostname: server6.am.acme1.com
Hostname: server7.am.acme1.com
Desired output:
Hostname: server1.am.acme1.com
account1 Jane Doe
account2 Joe Smith
Hostname: server4.am.acme1.com
account1 Jalen Tulip
account2 LeBron Jim
Thanks,
CSTORM
Hostname: server1.am.acme1.com
account1 Jane Doe
account2 Joe Smith
Hostname: server2.am.acme1.com
Hostname: server3.am.acme1.com
Hostname: server4.am.acme1.com
account1 Jalen Tulip
account2 LeBron Jim
Hostname: server5.am.acme1.com
Hostname: server6.am.acme1.com
Hostname: server7.am.acme1.com
Desired output:
Hostname: server1.am.acme1.com
account1 Jane Doe
account2 Joe Smith
Hostname: server4.am.acme1.com
account1 Jalen Tulip
account2 LeBron Jim
Thanks,
CSTORM