regex - selecting all pairs of words in a string in bash -


How can you select all the pairs of later words in a text in the bash?

For example, for the string test test test

  test tet test test tezt   

Should be changed in I have tried to use regular expressions, but it adds half the pairs only after the start of the maitter, where it is omitted, eg echo "Test Test Test Tzat". Grep -Po '[a-zA-Z] + [a-zA-Z] +' does not produce only the first and third output, not the second.

Please note: the original string is guaranteed to include only spaces and letters

EDIT: I need a solution that I will later get pipeline in another program I can do

You can use awk :

  s = 'test test test tezt' awk -v RS = '' 'NR & gt; 1 {Print P, $ 1} {p = $ 1} '& lt; & Lt; & Lt; "$ S" Exam Test Test Test Test    

Comments

Popular posts from this blog

java - ImportError: No module named py4j.java_gateway -

python - Receiving "KeyError" after decoding json result from url -

.net - Creating a new Queue Manager and Queue in Websphere MQ (using C#) -