I want to extract part of a line using sed and backreference
-1
votes
1
answer
958
views
1.The Greater Company :(Ranked 2)
5.United Taxi Service :(Ranked 3)
31.The Cacao Company :(Ranked 4)
40.Monster Inc. :(Ranked 5)
55.Afala, Industrial Strength :(Ranked 6)
60.The North Company :(Ranked 7)
I want to display just the company number and company name. I do not want the rest of the line to be displayed.
1.The Greater Company
5.United Taxi Service
31.The Cacao Company
40.Monster Inc.
55.Afala, Industrial Strength
60.The North Company
I can do this by sed 's/: .* //' filename.txt. How would I use this pattern with back reference so I can achieve the above result. The pattern that I want to match would be ([0-9]* .* :).
Asked by Rashad
(141 rep)
Feb 16, 2018, 01:08 AM
Last activity: Feb 28, 2018, 10:33 PM
Last activity: Feb 28, 2018, 10:33 PM