# Shows a list of your Call of Duty Servers (cod_lnxded)
# By Brejax

#!/bin/bash

# Execute command
output=$(ps aux | grep 'cod_lnxded' | grep -v grep | grep -v '/bin/')

# Formating..
echo "PID      MEM      Folder                                  CPU%"
echo "--------------------------------------------------------------"

echo "$output" | while read -r line; do
    pid=$(echo "$line" | awk '{print $2}')
    mem=$(echo "$line" | awk '{print $4}')
    command=$(echo "$line" | awk '{print $11}')
    folder=$(dirname "$command")
    cpu=$(echo "$line" | awk '{print $3}')

    printf "%-8s %-8s %-40s %-8s\n" "$pid" "$mem" "$folder" "$cpu"
done
