aboutsummaryrefslogtreecommitdiff
path: root/bin/slsf.awk
blob: 75efe7a46ba122b286e93bc0b18169b73eb15b47 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# Print all the hosts from ssh_config(1) files

# Manage the processing flag (starts set in each file)
BEGIN { sls = 1 }
FNR == 1 { sls = 1 }
/### sls/ { sls = 1 }
/### nosls/ { sls = 0 }

# Skip if we're ignoring hosts
!sls { next }
# Skip if this isn't a host line
$1 != "Host" { next }

# Add all the patterns after the keyword that don't have wildcards
{
    for (i = 2; i <= NF; i++) {
        if ($i !~ /[?*]/) {
            hosts[$i]++
        }
    }
}

# Print the complete list of hosts, sorted
END {
    for (host in hosts) {
        print host | "sort"
    }
}