Skip to content
This repository was archived by the owner on Feb 27, 2024. It is now read-only.

Commit c6c6de3

Browse files
committed
working script
1 parent b7dc461 commit c6c6de3

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

readme.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -39,15 +39,15 @@ In that way is more easy to do script on it in bash or other languages
3939
# How to use the script:
4040
# cat list.txt | xargs -n1 remove-page-by-url.sh
4141
42-
out=`wp get-by-url $1 --skip-plugins --skip-themes`
43-
if [[ ! -z $out ]]; then
44-
command=`cut -d'|' -f1 <<< $out`
45-
id=`cut -d'|' -f2 <<< $out`
46-
taxonomy=`cut -d'|' -f3 <<< $out`
47-
if [[ $taxonomy == 'post' ]]; then
48-
wp $command delete $id --skip-plugins --skip-themes
42+
out=$(wp get-by-url "$1" --skip-plugins --skip-themes)
43+
if [[ -n $out ]]; then
44+
command=$(cut -d'|' -f1 <<< "$out" | sed 's/^[[:blank:]]*//;s/[[:blank:]]*$//')
45+
id=$(cut -d'|' -f2 <<< "$out" | sed 's/^[[:blank:]]*//;s/[[:blank:]]*$//')
46+
taxonomy=$(cut -d'|' -f3 <<< "$out" | sed 's/^[[:blank:]]*//;s/[[:blank:]]*$//')
47+
if [[ "$taxonomy" == 'post' ]]; then
48+
wp "$command" delete "$id" --skip-plugins --skip-themes
4949
else
50-
wp $command delete $taxonomy $id --skip-plugins --skip-themes
50+
wp "$command" delete "$taxonomy" "$id" --skip-plugins --skip-themes
5151
fi
5252
fi
5353
```

0 commit comments

Comments
 (0)