All you are doing with xattr is manipulating Spotlight metadata. You will need to set the comment field as seen in a Finder Get Info via Finder itself. Here is a script that you can run in the Terminal that will either set or remove the current Finder comment field.
if the script name is cmt.zsh, you will need to first make it executable:
chmod +x ./cmt.zsh
Usage:
./cmt.zsh ~/Documents/somepath/file.txt "" # clear the Finder comments on some file
./cmt.zsh ./file.txt "New comment string" # adds a new Finder comment
Zsh script:
#!/bin/zsh
# Zsh script to clear, or set Finder Get Info comment field
# Adapted from: https://stackoverflow.com/questions/42889678/upload-comments-to-file-metadata-get-info-mac-command-line
# absolute file path
fpath="${1:a}"
# new comment string including ""
newcmt="$2"
# existing comment string or none
oldcmt=$(mdls -r -nullMarker "" -n kMDItemFinderComment "$fpath")
# get just the filename without its path
printf "%s (comment): %s\n" "${fpath:t}" "$oldcmt"
printf "%s (updated): " "${fpath:t}"
osascript -e "set filepath to (POSIX file \"$fpath\" as alias)" \
-e "tell application \"Finder\" to set the comment of filepath to \"$newcmt\""
exit 0
You can run this Zsh script from within Bash. In Catalina, Zsh replaces Bash as the default Shell.
Terminal output with no pre-existent Finder comment:

and Get Info Comments from this file:
