You can use simple AWK way to extract the domain name as follows:
echo http://example.com/index.php | awk -F[/:] '{print $4}'
OUTPUT: example.com
🙂
More Related Contents:
- Awk – replace coumn 2 in table 1 from coumn 2 in table 2 based on matching data in column 1 (common between tables)
- What is the best regular expression to check if a string is a valid URL?
- Getting parts of a URL (Regex)
- bash regex with quotes?
- How to get domain name from URL
- Find and kill a process in one line using bash and regex
- RE error: illegal byte sequence on Mac OS X
- Bash Regular Expression — Can’t seem to match any of \s \S \d \D \w \W etc
- How do I use regular expressions in bash scripts?
- Using the star sign in grep
- How to match digits in regex in bash script
- Regex to check if valid URL that ends in .jpg, .png, or .gif
- Regular expressions in a Bash case statement
- Regex matching in a Bash if statement
- Extract substring using regexp in plain bash
- Search and replace in bash using regular expressions
- Why is sed not recognizing \t as a tab?
- What does ‘\K’ mean in this regex?
- Can a URL contain a semicolon and still be valid?
- Insert linefeed in sed (Mac OS X)
- Does bash support word boundary regular expressions?
- How do I use a regex in a shell script?
- replace a unknown string between two known strings with sed
- Recursively change file extensions in Bash
- Google Sheets Formula for Extracting Domain From Website?
- Why does BASH_REMATCH not work for a quoted regular expression?
- How to change date format in sed?
- How to execute a Bash command only if a Docker container with a given name does not exist?
- Grep and regex – why am I escaping curly braces?
- Bash – Regex for HTML contents