I have a script like this:
#!/bin/bash
REGEX='(www\.)?\w*\.\w*'
echo "$1" | grep -P -o $REGEX
DOMAIN="$1" | grep -P -o $REGEX
echo $DOMAIN
What I want to achieve is to get the domain from a full URL.
If I give as parameter the: http://example.com/
then I need the example.com
The first echo works.
How could I pass that expression into a variable? I need to pass later the DOMAIN
to a script.