Artificial intelligent assistant

How to match words and ignore multiple spaces? The following syntax should match the "Ambari Server running", but how to match in case there are multiple spaces between words? How to ignore spaces between words? echo "Ambari Server running" | grep -i "Ambari Server running" echo "Ambari Server running" | grep -i "Ambari Server running" echo " Ambari Server running" | grep -i "Ambari Server running" The expected results should be: Ambari Server running Ambari Server running Ambari Server running

Use `tr` with its `-s` option to compress consecutive spaces into single spaces and then `grep` the result of that:


$ echo 'Some spacious string' | tr -s ' ' | grep 'Some spacious string'
Some spacious string


This would however not remove flanking spaces completely, only compress them into a single space at either end.

Using `sed` to remove the flanking blanks as well as compressing the internal blanks to single spaces:


echo ' Some spacious string' |
sed 's/^[[:blank:]]*//; s/[[:blank:]]*$//; s/[[:blank:]]\{1,\}/ /g'


This could then be passed through to `grep`.

xcX3v84RxoQ-4GxG32940ukFUIEgYdPy 0ff8888d1f89a34d2a0523d55c3549f9