Skip to content

Instantly share code, notes, and snippets.

@BANOnotIT
Created March 14, 2019 16:02
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save BANOnotIT/0ae194d8b517c3706a086fe1b6366db4 to your computer and use it in GitHub Desktop.
Save BANOnotIT/0ae194d8b517c3706a086fe1b6366db4 to your computer and use it in GitHub Desktop.
program="BEGIN{prev = \"\"} \
\
/^# file: / {\
prev = substr(\$0, 9)\
}\
\
/$2/ {\
print prev;\
prev=\"\"\
}\
\
/^\$/ {\
prev=\"\"\
}"
OLDIFS=$IFS
IFS=$'\n'
# read all file name into an array
fileArray=($(getfattr -dRh $1 2>/dev/null | awk "$program"))
# restore it
IFS=$OLDIFS
# get length of an array
tLen=${#fileArray[@]}
# use for loop read all filenames
for (( i=0; i<${tLen}; i++ ));
do
setfattr -hx $2 "${fileArray[$i]}"
done
@BANOnotIT
Copy link
Author

Example

bash remove_xdg_urls.bash ~/Downloads user.xdg.origin.url

@red-hara
Copy link

Slash is missing at line 31:
setfattr -hx $2 "/${fileArray[$i]}"

@BANOnotIT
Copy link
Author

Slash is missing at line 31:
setfattr -hx $2 "/${fileArray[$i]}"

No. This script only works with relative paths not absolute.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment