Skip to main content
edited body
Source Link
Costas
  • 15k
  • 24
  • 38

If you don't intend to make some operation with text the sed usage seems is more resonable

sed -En 's/.* (\S+)M$/\1/p'

-E let's to avoid meta-characters usage with backslash (\(, \+, etc.)

-n suppress output exept ordered by p

s/ substitute

.* first part of the line for space (the last space becouse greadygreedy)

() "revers link" - you can call pattern inside brackets by \number

\S every non-space simbol (everything exept :blank:)

+ one or more previous simbol

M$ "M" at the end of line

/p print line where substitution is made

Meaning is "Substitute whole line by pattern inside brackets and print lines where such substitution is made only"

If you don't intend to make some operation with text the sed usage seems is more resonable

sed -En 's/.* (\S+)M$/\1/p'

-E let's to avoid meta-characters usage with backslash (\(, \+, etc.)

-n suppress output exept ordered by p

s/ substitute

.* first part of the line for space (the last space becouse gready)

() "revers link" - you can call pattern inside brackets by \number

\S every non-space simbol (everything exept :blank:)

+ one or more previous simbol

M$ "M" at the end of line

/p print line where substitution is made

Meaning is "Substitute whole line by pattern inside brackets and print lines where such substitution is made only"

If you don't intend to make some operation with text the sed usage seems is more resonable

sed -En 's/.* (\S+)M$/\1/p'

-E let's to avoid meta-characters usage with backslash (\(, \+, etc.)

-n suppress output exept ordered by p

s/ substitute

.* first part of the line for space (the last space becouse greedy)

() "revers link" - you can call pattern inside brackets by \number

\S every non-space simbol (everything exept :blank:)

+ one or more previous simbol

M$ "M" at the end of line

/p print line where substitution is made

Meaning is "Substitute whole line by pattern inside brackets and print lines where such substitution is made only"

added 582 characters in body
Source Link
Costas
  • 15k
  • 24
  • 38

If you don't intend to make some operation with text the sed usage seems is more resonable

sed -En 's/.* (\S+)M$/\1/p'

-E let's to avoid meta-characters usage with backslash (\(, \+, etc.)

-n suppress output exept ordered by p

s/ substitute

.* first part of the line for space (the last space becouse gready)

() "revers link" - you can call pattern inside brackets by \number

\S every non-space simbol (everything exept :blank:)

+ one or more previous simbol

M$ "M" at the end of line

/p print line where substitution is made

Meaning is "Substitute whole line by pattern inside brackets and print lines where such substitution is made only"

If you don't intend to make some operation with text the sed usage seems is more resonable

sed -En 's/.* (\S+)M$/\1/p'

If you don't intend to make some operation with text the sed usage seems is more resonable

sed -En 's/.* (\S+)M$/\1/p'

-E let's to avoid meta-characters usage with backslash (\(, \+, etc.)

-n suppress output exept ordered by p

s/ substitute

.* first part of the line for space (the last space becouse gready)

() "revers link" - you can call pattern inside brackets by \number

\S every non-space simbol (everything exept :blank:)

+ one or more previous simbol

M$ "M" at the end of line

/p print line where substitution is made

Meaning is "Substitute whole line by pattern inside brackets and print lines where such substitution is made only"

Source Link
Costas
  • 15k
  • 24
  • 38

If you don't intend to make some operation with text the sed usage seems is more resonable

sed -En 's/.* (\S+)M$/\1/p'