mirror of
https://github.com/shokinn/.files.git
synced 2026-07-22 14:16:07 +00:00
Add ifgrep function to match network devices by IP address pattern
This commit is contained in:
parent
501d76dbb9
commit
b1fb176564
1 changed files with 16 additions and 0 deletions
|
|
@ -204,6 +204,22 @@ addec() {
|
|||
}
|
||||
|
||||
{%@@ if distro == 'macos' @@%}
|
||||
|
||||
#######################################
|
||||
# Shows all devices matching a given IP address Pattern.
|
||||
# Globals:
|
||||
# None
|
||||
# Arguments:
|
||||
# IP address pattern to match
|
||||
# Outputs:
|
||||
# Matching network device information
|
||||
# Returns:
|
||||
# None
|
||||
#######################################
|
||||
ifgrep() {
|
||||
ifconfig | awk -v q="$1" '/^[^ \t]/ {if(block&&hit) print block; block=$0; hit=0; next} {block=block ORS $0} $1=="inet" && index($2,q) {hit=1} END{if(block&&hit) print block}';
|
||||
}
|
||||
|
||||
#######################################
|
||||
# Shows a netstat -tulpn styled output on mac.
|
||||
# Globals:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue