Format results in Bash

For example, I have test.txt with the following line:


I want to get “Test” and “Test1“, both are after L1~00~00~00~00~00~ with the following format.

Test, Test1

I already have this line in my bash script:

grep -oP 'L1(?:.[ws]*){5}.(K[ws]*)' < test.txt

But it returns a different format:


How can I achieve this by adding sed in my script? I’m still a newbie. I hope somebody could help me. Thanks

Source: bash

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.