You could try something like this:
echo 'maps.google.com' | rev | cut -d'.' -f 1 | rev
Explanation
rev
reverses “maps.google.com” to bemoc.elgoog.spam
cut
uses dot (ie ‘.’) as the delimiter, and chooses the first field, which ismoc
- lastly, we reverse it again to get
com
More Related Contents:
- How to read a file line by line and making a new file for each line having same filename as last word of each line? [closed]
- How to permanently set $PATH on Linux/Unix [closed]
- How do I use sudo to redirect output to a location I don’t have permission to write to? [closed]
- Read values into a shell variable from a pipe
- Aborting a shell script if any command returns a non-zero value
- Bash ignoring error for a particular command
- Fastest way to find lines of a file from another larger file in Bash
- How to replace spaces in file names using a bash script
- Shell script: Run function from script over ssh
- How can I quickly sum all numbers in a file?
- Bash script process substitution Syntax error: “(” unexpected
- Setting environment variables in Linux using Bash
- What does `set -x` do?
- “find: paths must precede expression:” How do I specify a recursive search that also finds files in the current directory?
- Does “argument list too long” restriction apply to shell builtins?
- Given two directory trees, how can I find out which files differ by content? [closed]
- bash alias command with both single and double quotes
- Take nth column in a text file
- How to remove non UTF-8 characters from text file
- Uppercasing First Letter of Words Using SED
- Find the files that have been changed in last 24 hours
- Tar a directory, but don’t store full absolute paths in the archive
- Get last dirname/filename in a file path argument in Bash
- bash command not found when setting a variable
- How to obtain the number of CPUs/cores in Linux from the command line?
- Exit code of variable assignment to command substitution in Bash
- Move all files except one
- Using `date` command to get previous, current and next month
- Problem with Bash output redirection [duplicate]
- bash: set array env variable and de-referencing it from any shell script fails