Last active
December 9, 2023 14:04
-
-
Save chockenberry/e33df6b0f4f201bd161763946158c11c to your computer and use it in GitHub Desktop.
A simple shell script to reset CoreSimulator
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
pids=`ps axo pid,command | grep CoreSimulator | grep -v "grep CoreSimulator" | cut -c 1-5` | |
if [ "$1" = "go" ]; then | |
kill -9 $pids | |
elif [ "$1" = "echo" ]; then | |
echo $pids | |
else | |
pid_param=`echo $pids | tr -s ' ' ','` | |
ps -p $pid_param -o pid,command | |
fi |
In case they're not in your arsenal, check out pgrep
/pkill
.
Rather than the grep/grep -v you can use grep "[C]oreSimulator". The regexp won't match the parameter to grep.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@hisaac Good catch. I've updated the script so it just uses column position 1 through 5. That catches the process ids with less than 5 digits.