I want to create script which will count symbols from string "word blah-blah word one more time word again". It will count symbols before "word" only and every "word" should be written to new string. So output of script should looks like that:
word 0 ## (no symbols)
word 9 ##blah-blah
word 11 ##one more time
All i got in this moment:
#!/bin/bash
$word="word blah-blah word one more time word again"
echo "$word" | grep -o word
Output show me only "word" from $word. How i can count chars before "word"?