fix: cleanup fp command

This commit is contained in:
max_richter 2021-07-14 19:14:02 +02:00
parent 1b30f4b7b1
commit 24afcffe52

View File

@ -2,33 +2,26 @@
function fp(){ function fp(){
for p in "$@"
do
PORT=$var;
if [ "$(which lsof)" = "lsof not found" ]; then if [ "$(which lsof)" = "lsof not found" ]; then
echo "lsof not installed" echo "lsof not installed"
else else
for PORT in "$@"
do
if [ "$PORT" != "" ]; then
#echo "checking ($PORT)"
PIDS="$(lsof -t -i:$PORT)" PIDS="$(lsof -t -i:$PORT)"
AMOUNT=$(wc -w<<<$PIDS); AMOUNT=$(wc -w<<<$PIDS);
if [ $AMOUNT = 0 ]; then if [ $AMOUNT = 0 ]; then
echo "No processes use port $PORT"; echo "No processes use port $PORT";
else else
echo "Killing $AMOUNT process(es) using port $PORT"; echo "Killing $AMOUNT process(es) using port $PORT";
echo "$PIDS" | while IFS= read -r pid ; do echo "$PIDS" | while IFS= read -r pid ; do
kill -9 $pid; kill -9 $pid;
done done
fi fi
fi fi
done done
fi
} }