So I'm writing a script that downloads images from a certain website. Things are going great thus far, but I've run into the issue of inputting URLs containing the character "&". Is there a way to take inputs like this without needing to put quotes in the command input itself? In other words, am I able to take the raw input?
Example code:
#!/bin/bash
# Sample input: https://website.com/posts?page=2&tags=sometag
# https://website.com/posts?tags=sometag&page=2
# https://website.com/posts?tags=sometag
# https://website.com/posts?page=2
# https://website.com/posts
folder=""
if [[ "$folder" == "" ]]; then
case "$1" in
*website.com/posts*) if [[ "$1" == *"tags="* ]]; then
folder="/default/tags"
echo "$folder"
else
folder="/default/posts"
echo "$folder"
fi;;
esac
fi
# Expected output: /default/tags (page 2)
# /default/tags (page 2)
# /default/tags (page 1)
# /default/posts (page 2)
# /default/posts (page 1)
# Actual output: /default/posts (page 2)
# /default/tags (page 1)
# /default/tags (page 1)
# /default/posts (page 2)
# /default/posts (page 1)
Any help is appreciated!