user2570205
user2570205

Reputation: 137

SED/awk remove string until first occurrence

I have string like below (one long line with a space in the middle):

100">16946083;Rapid_0201_Corrected_Pre_Sept12thDate.txt;5744-2;RapidReporting;RR_20160606115224556.fin.bc_lerr.xml "100">16946083;Rapid_0201_Corrected_Pre_Sept12thDate.txt;5744;RapidReporting;RR_20160606115224556.fin.bc_lerr.xml

I want to remove the varying length set of digits between > and ; which, in this example, means remove (the first occurrence of) 16946083.

This text is an output of my sed and cut commands.

Upvotes: 0

Views: 1304

Answers (2)

karakfa
karakfa

Reputation: 67507

a more robust version will be

sed -r 's/>[^;]+;/>;/'

Upvotes: 0

Eric Renouf
Eric Renouf

Reputation: 14500

How about

sed -e 's/>[0-9]\+;/>;/'

which will find the first > any number of digits and the ; and replace that whole string with just >;

Upvotes: 1

Related Questions