Created
February 16, 2021 03:28
-
-
Save yawaramin/0f15292b605a96b24943bf09dade1fa8 to your computer and use it in GitHub Desktop.
Get or set file comment (Linux)
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
#!/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