Solved

sed for stripping out text

Posted on 2001-09-13
2
187 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
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

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

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

Suggested Solutions

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…
This Micro Tutorial will teach you how to censor certain areas of your screen. The example in this video will show a little boy's face being blurred. This will be demonstrated using Adobe Premiere Pro CS6.
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …

831 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