I am trying to visualise all new sockets created after a save point in Debian Linux 5.14:
ss -a > state
ss -a | grep -v -f state
Expected output : Nothing
Observed output : The same as ss -a
I checked the content of the file and every line does properly end with a $ indicating it's multine.
Can't truely grasp why this happens, did anyone encounter this before ?
CodePudding user response:
- Use
-F
so the lines are treated as fixed strings and not regexes. This ensures that items like*
and[::ffff:127.0.0.1]
are not treated as wildcards and character classes. - For good measure, use
-x
to match whole lines.
$ ss -a > state
$ wc -l < state
1867
$ ss -a | grep -vxFf state | wc -l
56