By unifyeel


2019-03-23 01:19:59 8 Comments

I need to remove text between the delimiters "<" and ">", but there are multiple instances of these on each line of my text file.

For example, I want to turn this:

person 1, person 2<[email protected]>, person 3<[email protected]>, person 4<[email protected]>`

Into this:

person 1, person 2, person 3, person 4  

I've tried to use a few things, including sed:

sed -e 's/<.*>//' filename.csv

but this removes everything between the first < and the last > giving the result person 1, person 2.

2 comments

@oguz ismail 2019-03-23 01:28:14

you can use a negated character class in your regex:

sed 's/<[^>]*>//g' filename.csv

@Benitok 2019-03-23 05:14:36

If you want to join the dark side, Perl lets you specify non-greedy wildcards with ?:

perl -pe 's/<.*?>//g' filename.csv

@unifyeel 2019-03-23 19:28:35

This worked great as well! I definitively appreciate the dark side.

Related Questions

Sponsored Content

14 Answered Questions

[SOLVED] Delete lines in a text file that contain a specific string

15 Answered Questions

[SOLVED] How can I remove the first line of a text file using bash/sed script?

  • 2008-12-04 02:50:16
  • Brent
  • 507850 View
  • 531 Score
  • 15 Answer
  • Tags:   bash scripting sed

4 Answered Questions

[SOLVED] extract lines between two same delimiters ( multi instances delimiters)

  • 2018-05-10 14:07:53
  • yuzhen
  • 110 View
  • 2 Score
  • 4 Answer
  • Tags:   regex linux awk sed

3 Answered Questions

[SOLVED] SED: Deleting text between two strings, repeated across the line

  • 2015-01-19 10:03:58
  • Hanna
  • 5717 View
  • 2 Score
  • 3 Answer
  • Tags:   bash sed

3 Answered Questions

[SOLVED] Search for text between two patterns with multiple lines in between

  • 2016-01-24 13:53:38
  • user5700466
  • 823 View
  • 0 Score
  • 3 Answer
  • Tags:   regex bash awk sed

3 Answered Questions

Extracting text between multiple Delimiters

3 Answered Questions

4 Answered Questions

[SOLVED] Removing text between "|" delimiter and "," delimiter using shell script

  • 2013-06-06 20:10:16
  • Matthew
  • 988 View
  • 1 Score
  • 4 Answer
  • Tags:   regex unix sh ksh

1 Answered Questions

[SOLVED] Using regex to remove text between delimiter in java

  • 2012-11-08 07:08:44
  • user1731199
  • 1374 View
  • 2 Score
  • 1 Answer
  • Tags:   java regex

1 Answered Questions

[SOLVED] Using sed to print between delimiters

  • 2011-05-16 21:22:52
  • Mark
  • 719 View
  • 1 Score
  • 1 Answer
  • Tags:   printing sed

Sponsored Content