mardi 21 février 2017

Finding character location of all instances of a string in bash

I'm trying to find the location of all instances of a string in a particular file; however, the code I'm currently running only returns the location of the first instance and then stops there. Here is what I'm currently running:

str=$(cat temp1.txt) 
tmp="${str%%<C>*}"

if [ "$tmp" != "$str" ]; then
echo ${#tmp}
fi

The file is only one line of string and I would display it but the format questions need to be in won't allow me to add the proper amount of spaces between each character.

Aucun commentaire:

Enregistrer un commentaire