I need to create a tool to tokenize an input list. I would be providing a text file containing a list of subdomains in the following manner:
abc.xyc.kkk.com
hjk.pol.lll.kkk.com
...
And the output need to be :
abc
xyz
kkk
hjk
...
The delimiter is '.'
I have tried out the following code, which does not seem to be working:
#!/bin/bash
STRING= cat $1
IFS='.' read -ra VALUES <<< "$STRING"
## To print all values
for i in "${VALUES[@]}"; do
echo $i
done
.comomitted – is it becausecomis in blacklist or simply becausecomis the last token in the current whitespace-free block? Also, I assume….xyc.…→… xyz …is a typo – you may want to fix that. Please edit your question using the grey edit button below your question.STRING= cat $1is a duplicate of Why does a space in a variable assignment give an error in bash?, and How do I set a variable to the output of a command in bash?.