Search code examples
shellcut

Linux cut fields from inside text line


I want to cut ;XXm m:;XXm from this lines:

Xmorg.camunda.bpm.engine.context          ;XXm m:;XXm ENGINE-XXXXX Exception while
Xma.ExceptionLoggingFilter    ;XXm m:;XXm Uncaught exception thrown
Xmb.ExceptionHandlerController;XXm m:;XXm handle exception

This cuts whole line:

cut -d" " -f2,3 

The result I want is:

Xmorg.camunda.bpm.engine.context          ENGINE-XXXXX Exception while
Xma.ExceptionLoggingFilter    Uncaught exception thrown
Xmb.ExceptionHandlerController handle exception

or

Xmorg.camunda.bpm.engine.context ENGINE-XXXXX Exception while 
Xma.ExceptionLoggingFilter Uncaught exception thrown
Xmb.ExceptionHandlerController handle exception

Solution

  • I want reverse result :), I want to cut ;XXm m:;XXm from this fil

    cut --complement -d" " -f2,3 
    

    or

    cut -d" " -f1,4-
    

    Learn about regexes.

    sed 's/;XXm m:;XXm//'