Query with sed bash script string

0

I have the following example:

cat test.txt

Showing the following:

  

juan maria juan maria juan maria maria juan maria juan maria juan   roberto roberto roberto roberto roberto roberto

To separate 2 from 2 each chain I do it using a for loop, but to summarize, if I use:

cat test.txt | sed 's/../& /g'

I get the following output:

  

juan m ar ia ma ri a juan ro be r rt o ro be rt o

How do I make sed so that I do not care about the repeated ones?

Greetings

    
asked by LestherSRV 10.11.2018 в 13:21
source

1 answer

2

Fix it temporarily by doing the following:

sed was taking the empty spaces:

temp="0001 0002 0001 0002 0001 0002" echo $ temp | grep -v "" | sed 's /../& / g ' 00 01 0 00 2 00 01 0 00 2 00 01 0 00 2

With tr -d as delimiter: echo $ temp | tr -d "" | sed 's /../& / g ' 00 01 00 02 00 01 00 02 00 01 00 02

I hope someone serves you.

    
answered by 11.11.2018 в 19:12