Solved

sed for stripping out text

Posted on 2001-09-13
2
189 Views
Last Modified: 2010-04-21
I am trying to use sed to strip out everything after the comma in a file that contains the following text:

#text1-text2,text1.text2,,,,text
#text31-text32,text31.text32,,,,text
etc

I want to be left with

#text1-text2
#text31-text32
etc

I am using sed for windows and the command I am using is:

sed "s/,*$//" < input.txt >output.txt

it is not working and I can't work out what I am doing wrong.

Can anyone help?

Craigggg

0
Comment
Question by:craigggg
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 3

Accepted Solution

by:
interiot earned 100 total points
ID: 6481071
sed "s/,.*$//" < input.txt >output.txt


* in regular expressions is different than globs

* means "match the previous character 0 or more times"
. means "match any character"
0
 

Author Comment

by:craigggg
ID: 6481855
Unfortunately I did manage to work it out last night, but your answer is bang on.  Thanks for the guidance.

Craigggg
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Have you ever been frustrated by having to click seven times in order to retrieve a small bit of information from the web, always the same seven clicks, scrolling down and down until you reach your target? When you know the benefits of the command l…
The purpose of this article is to fix the unknown display problem in Linux Mint operating system. After installing the OS if you see Display monitor is not recognized then we can install "MESA" utilities to fix this problem or we can install additio…
Are you ready to implement Active Directory best practices without reading 300+ pages? You're in luck. In this webinar hosted by Skyport Systems, you gain insight into Microsoft's latest comprehensive guide, with tips on the best and easiest way…
Finding and deleting duplicate (picture) files can be a time consuming task. My wife and I, our three kids and their families all share one dilemma: Managing our pictures. Between desktops, laptops, phones, tablets, and cameras; over the last decade…

730 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question