I have a file named .sock
in /var/spool/
dir.
Here is the result of ls -al /var/spool/
drwxr-xr-x. 9 root root 121 Dec 16 09:55 .
drwxr-xr-x. 19 root root 267 Dec 14 10:47 ..
drwxr-xr-x. 2 root root 63 Oct 28 2019 anacron
drwx------. 2 root root 6 Feb 13 2019 cron
drwxr-xr-x. 2 root root 6 Dec 14 2017 lpd
drwxrwxr-x. 2 root mail 22 Dec 14 10:47 mail
prw-r--r--. 1 telegraf root 0 Dec 17 10:04 nethermind.sock
drwxr-xr-x. 16 root root 201 Jul 29 2019 postfix
drwxr-xr-x. 3 root root 19 Oct 28 2019 rhsm
drwx------. 2 root root 6 Sep 6 2018 up2date
You can see the nethermind.sock
file is marked as prw-r--r--.
I want to delete this file, so I write this in my script -
NETHERMIND_SOCK="/var/spool/nethermind.sock"
PARITY_SOCK="/var/spool/parity.sock"
if [ -f $NETHERMIND_SOCK ]; then
rm -f $NETHERMIND_SOCK
elif [ -f $PARITY_SOCK ]; then
rm -f $PARITY_SOCK
else
echo ".sock not found"
fi
It always gives .sock not found
I tried then to find and delete like -
sudo find / -type f -name "*.sock" -exec rm -f {} +
But it seems that the file is not findable.
If I do sudo find /var/spool/ -type f -name "nethermind.sock"
, It doesn't return anything.
I am not sure about mark p
from here prw-r--r--.
Here is a link actually what p
marked means. But find
command is not able to find piped file.
As your file isn't a regular file but a pipe you can't use
[ -f ...]
or-type f
. Use[ -p ... ]
opr-type p
instead:or