I'm using centOS 7, and I'm trying to check what is the pid of a process using port X/tcp with "fuser" command, through a bash script, like so:
some_pid=$(fuser X/tcp) > /dev/null
another_pid=$(fuser Y/tcp) > /dev/null
...
if [[ -z "$some_pid" ]]; then ...
Although I don't want anything to be printed to the console, the results are:
X/tcp:
Y/tcp:
...
When I try to run fuser with -s, then the if statment returns false, because the result of the fuser is empty, for some reason.
How can I avoid the unwanted printing? Why when I run fuser in silent mode it returns empty?