Quantcast
Channel: sed/awk/python replace all spaces between characters after string match - Unix & Linux Stack Exchange
Viewing all articles
Browse latest Browse all 2

sed/awk/python replace all spaces between characters after string match

0
0

I want to delete all spaces between characters after an initial match. An example is

exmpl 0 t h i s a r e t he spaces to d e l e t e
exmpl 1 m o r e spaces to d e l
exmpl 2 o r s m t h completely d i f f e r e n t
exmpl 12 y e t another l i n e

which's output should be:

exmpl 0 thisarethespacestodelete
exmpl 1 morespacestodel
exmpl 2 orsmthcompletelydifferent
exmpl 12 yetanotherline

The spaces between the initial text and the numbers, and the numbers and the following text could also be tabs.

I am able to match the first and second part, e.g., in sed by

sed -i 's/\(exmpl\s*[0-9]*\s*\)\(.*\)/\1\2/'

but I can't figure out to remove all the spaces in \2.


Viewing all articles
Browse latest Browse all 2

Latest Images

Trending Articles





Latest Images