]> git.nbdom.net Git - nb.git/commitdiff
etc/profile.d/functions
authorNicolas Boisselier <nicolas.boisselier@gmail.com>
Sat, 1 Apr 2017 22:00:36 +0000 (23:00 +0100)
committerNicolas Boisselier <nicolas.boisselier@gmail.com>
Sat, 1 Apr 2017 22:00:36 +0000 (23:00 +0100)
etc/profile.d/functions

index 173ad523b9abcd5c4ef71910a8c4911c39eaafee..fb80ef44737321b25a42b3cec9e0b2f77c85bc56 100644 (file)
@@ -197,7 +197,7 @@ shell_ssh() {
 
 ips() {
   shell_help "Usage: $FUNCNAME [INTERFACE]. Print ip adresses." "$@" && return 1
-  ifconfig | perl -ne 'BEGIN{$e=shift @ARGV; $e=~s/\W+/|/g}; /^(\w+)\s+/ and $i=$1; /^\s*inet (?:addr:)?([\d\.]+)/ and ($_=$1) ne "127.0.0.1" and (!$e or $i=~/^($e)$/) and print "$_\n"' "$*"
+  ( ip addr show || ifconfig ) 2>/dev/null | awk '/^[\t ]*inet /{sub("^[^0-9]*","",$2); sub("/[0-9]+","",$2); if ($2 != "127.0.0.1"){print $2}}'
 }
 
 env_add_path() {