Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!

Analysis | 8 comments | Create New Account
Click here to return to the 'Analysis' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Authored by: Lizard_King on Dec 18, '02 03:01:57PM
Kewl hint! However, I'm a junky for understanding all of the innards of commands and scripts and being clear on exactly what they do. Here's my interpretation of this command (with a bunch of holes that I hope kind folks can fill in for me so I can learn!):

% netstat -f inet -n | grep '.548 ' | awk '{ print $5 }' | sed 's/.[^.]*$//'

netstat -f inet -n
show statistics only for the 'inet' address family and display network addresses as numbers

grep '.548 '
find the instances where connections are made to the apple file sharing port

awk '{ print $5 }'
scan for the fifth element and print it

sed 's/.[^.]*$//
change the output somehow (I'm not sed fluent at all)

[ Reply to This | # ]
Authored by: signals on Dec 18, '02 03:46:38PM

> sed 's/.[^.]*$//
> change the output somehow (I'm not sed fluent at all)

The pattern s/{regex}/{string}/ is a search and replace function.

The regex is ".[^.]*$" which matches the part of the line from the last "." to the end of the line (see the manpage for ed(1) for help with regular expressions)

The string to replace it with is nothing ("//").

So this will take everything from the last period on the line to the end of the line and remove it (replaces it with nothing).

This drops the port numbers from the end of the ip numbers netstat returns.


[ Reply to This | # ]