Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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

This comment has been minimized.

Copy link
Owner Author

commented Mar 14, 2019

Example

bash remove_xdg_urls.bash ~/Downloads user.xdg.origin.url
@red-hara

This comment has been minimized.

Copy link

commented Mar 14, 2019

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

@BANOnotIT

This comment has been minimized.

Copy link
Owner Author

commented Mar 14, 2019

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
You can’t perform that action at this time.