Remove all the characters after last space per line including it

echo 'The quick brown fox jumps over the lazy dog' | sed 's|\(.*\) .*|\1|'
It his example removes ' dog', last space included.
Sample Output
The quick brown fox jumps over the lazy

By: bugmenot
2021-07-15 20:01:32

What Others Think

I'm irritable to reveal this page. I need to thank you for your time for this especially fundamental read!! I certainly genuinely regarded all pieces of it and I additionally have saved you to take a gander at new data in your site.
sumanrajput · 1 week and 2 days ago
Every one of moderate data is set up by utilizing tremendous numbers identified with experiencing immense agreement. I'm restless to do this ultimately essentially.
sumanrajput · 1 week and 2 days ago
I like this article for the inside and out empowering substance and awesome correspondence. I got so pulled in with this material that I was unable to quit taking a gander at.
sumanrajput · 1 week and 2 days ago
Everything is very open with a clear description of the issues. It was truly informative. Your website is very helpful. Many thanks for sharing!
Adkins562 · 6 days ago
This is a fantastic blog post. Your blog post has been quite helpful to us. Following your visit to your article, you will discover a variety of options. I knew exactly what I was looking for. Thank you for such an informative article; please keep it up. and
kanejoyce · 3 days ago
This is an excellent blog post. Your blog content was quite beneficial to us. Following your visit to your article, you will be presented with a number of choices. I had a clear idea of what I was looking for. Thank you for writing such a useful essay; please keep it up. Regards, Nursing Essay UK
hellonwood40 · 2 days ago
I just stumbled upon your weblog and wanted to say that I have really enjoyed browsing your blog posts. Thank you for sharing. Read more
johnlead · 13 hours ago
The entire look of your website is excellent, let alone the content! Also visit my web page - companies
sinessmen · 11 hours ago

What do you think?

Any thoughts on this command? Does it work on your machine? Can you do the same thing with only 14 characters?

You must be signed in to comment.

What's this? is the place to record those command-line gems that you return to again and again. That way others can gain from your CLI wisdom and you from theirs too. All commands can be commented on, discussed and voted up or down.

Share Your Commands

Stay in the loop…

Follow the Tweets.

Every new command is wrapped in a tweet and posted to Twitter. Following the stream is a great way of staying abreast of the latest commands. For the more discerning, there are Twitter accounts for commands that get a minimum of 3 and 10 votes - that way only the great commands get tweeted.


Subscribe to the feeds.

Use your favourite RSS aggregator to stay in touch with the latest commands. There are feeds mirroring the 3 Twitter streams as well as for virtually every other subset (users, tags, functions,…):

Subscribe to the feed for: