4 ms·
It's unreliable, because you don't know where you'll find 'inet ' or what's the specific spacing of the output. Also, that's not the ip, because you've still go
by viraptor 10y ago
It's unreliable, because you don't know where you'll find 'inet ' or what's the specific spacing of the output. Also, that's not the ip, because you've still got the cidr attached.
And no, fstab is not easy either. For example it fails for:
# /tmp has option_blah in order to ...
changing it to:
# /tmp has option_blah,nosuid in order to ...
Confusing the next person to look at the well intended comment.
It's no impossible to implement fairly reliably, it's not going to take days to do, but you're likely make mistakes. And in both cases you're spawning extra processes instead of just getting the information you need.
PS. also slightly annoying is that everyone is so concerned about the text processing part that barely anyone checks what the tool itself can do. (ip -4 -o a s dev eno1 | awk '{print $4}')
- qwertyuiop924 10y ago>PS. also slightly annoying is that everyone is so concerned about the text processing part that barely anyone checks what the tool itself can do. (ip -4 -o a s dev eno1 | awk '{print $4}') Actually, I spend a while digging through the manpage to try and find this. ip has awful docs. As for the comment problem, yeah, not optimal.
- qwertyuiop924 10y agoOh, I forgot: the comment you showed wouldn't trigger my AWK script. Read it more carefully.
- viraptor 10y agoYes it will. If you mean the $2 part, the comment character takes the place of $1. Or did you mean something else? (either way, I tested it before posting)
- qwertyuiop924 10y agoNope, you're right. I just miscounted. You could always add && $1 != "#" To fix this, though.