If you want to create a shell script so you can change between MacOS dark mode and light mode from the Terminal (Unix) command line, put this source code in a file and name it something like dark:
osascript -e \ 'tell application "System Events" to tell appearance preferences to set dark mode to not dark mode'
Then make that file executable, and make sure it’s on your PATH. Now you can type
dark to toggle back and forth between dark mode and the regular light mode: