mirror of
https://github.com/m8tin/cis.git
synced 2025-12-06 07:48:26 +01:00
Scripts to determine network settings
This commit is contained in:
19
script/host/net/printAllShortManagedHostnamesFromHostsFile.sh
Executable file
19
script/host/net/printAllShortManagedHostnamesFromHostsFile.sh
Executable file
@@ -0,0 +1,19 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Select just lines containing 'managedHost'.
|
||||
# 1.) Remove everything after a '#' (including the #).
|
||||
# 2.) Remove every indenting.
|
||||
# 3.) Remove blanks (spaces or tabs) at the end of lines.
|
||||
# 4.) Replace blanks (spaces or tabs) with one ';' between the values.
|
||||
# 5.) Delete empty lines.
|
||||
# Then cut the second field
|
||||
# Then cut the first field to get the short hostname
|
||||
grep 'managedHost' /etc/hosts \
|
||||
| sed -e 's/#.*//' \
|
||||
-e 's/^[[:blank:]]*//' \
|
||||
-e 's/[[:blank:]]*$//' \
|
||||
-e 's/\s\+/;/g' \
|
||||
-e '/^$/d' \
|
||||
| cut -d';' -f2 \
|
||||
| cut -d'.' -f1
|
||||
|
||||
Reference in New Issue
Block a user