Skip to main content
added 249 characters in body
Source Link
Kusalananda
  • 355.8k
  • 42
  • 735
  • 1.1k

Pass it through

sed 's/^[^:]*: *//'

This sed substitution will delete everything from the beginning of the line up to and including the first : and any spaces after it.

If you have the string in a shell variable $a then

printf -- '-%s\n' "${a#*-}"

This uses the parameter expansion ${parameter#word} to delete everything up to and including the first -. The dash is inserted again by the printf. This does not use any external utilities when run in most modern shells.

Pass it through

sed 's/^[^:]*: *//'

This sed substitution will delete everything from the beginning of the line up to and including the first : and any spaces after it.

Pass it through

sed 's/^[^:]*: *//'

This sed substitution will delete everything from the beginning of the line up to and including the first : and any spaces after it.

If you have the string in a shell variable $a then

printf -- '-%s\n' "${a#*-}"

This uses the parameter expansion ${parameter#word} to delete everything up to and including the first -. The dash is inserted again by the printf. This does not use any external utilities when run in most modern shells.

Source Link
Kusalananda
  • 355.8k
  • 42
  • 735
  • 1.1k

Pass it through

sed 's/^[^:]*: *//'

This sed substitution will delete everything from the beginning of the line up to and including the first : and any spaces after it.