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

@Burrito 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

22 Answered Questions

[SOLVED] How to join multiple lines of file names into one with custom delimiter?

17 Answered Questions

[SOLVED] How to delete from a text file, all lines that contain a specific string?

16 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
  • 559192 View
  • 587 Score
  • 16 Answer
  • Tags:   bash scripting sed

1 Answered Questions

[SOLVED] adding && \ to each line on a text file except last line

  • 2020-02-20 12:24:11
  • X00145570
  • 76 View
  • 1 Score
  • 1 Answer
  • Tags:   bash awk sed

2 Answered Questions

4 Answered Questions

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

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

6 Answered Questions

[SOLVED] Capturing multiple line output into a Bash variable

  • 2009-03-05 04:32:18
  • Parker
  • 282006 View
  • 596 Score
  • 6 Answer
  • Tags:   bash variables

3 Answered Questions

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

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

3 Answered Questions

Extracting text between multiple Delimiters

4 Answered Questions

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

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

Sponsored Content