Skip to content

Instantly share code, notes, and snippets.

@yawaramin
Created February 16, 2021 03:28
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yawaramin/0f15292b605a96b24943bf09dade1fa8 to your computer and use it in GitHub Desktop.
Save yawaramin/0f15292b605a96b24943bf09dade1fa8 to your computer and use it in GitHub Desktop.
Get or set file comment (Linux)
#!/usr/bin/env sh
usage() {
cat <<EOF
USAGE
$(basename $0) FILENAME [COMMENT]
Get or set file comment.
ARGUMENTS
FILENAME
The file to get or set comment on.
COMMENT
The comment to set. If not provided, get the existing comment if any.
EOF
}
comment_attr=user.xdg.comment
filename="$1"
comment="$2"
if [ -z "$filename" ]
then
usage
elif [ -z "$comment" ]
then
getfattr -n "$comment_attr" "$filename"
else
setfattr -n "$comment_attr" -v "$comment" "$filename"
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment