Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

SED search word hugs of data and replace with blank

Status
Not open for further replies.

fpalero

MIS
Jan 10, 2017
6
PH
Hi,

Anyone can help on how to search and change using sed.

My text file:
"A"|"ExtCla436975E"|"20170108"|"activate"
"B"|"ExtClaArQ75EK"|"20170109"|"activate"
"C"|"ExtClaQYT64NF"|"20170110"|"ExtClaIPE46RT"
"D"|"ExtClaPLS34YZ"|"20170111"|"activate"
...

Need out file:
"A"|""|"20170108"|"activate"
"B"|""|"20170109"|"activate"
"C"|""|"20170110"|""
"D"|""|"20170111"|"activate"

Thanks in advance.

Regards,
FPalero
 
Define "hugs of data"???

Chris.

Indifference will be the downfall of mankind, but who cares?
Time flies like an arrow, however, fruit flies like a banana.

Never mind this jesus character, stars had to die for me to live.
 
Hi Christ,

Good Day!

Hugs of data, meaning millions of records in text file.

Regards,
FPalero
 
So;

Huge [amounts] of data is what you mean then.

"Hugs" are something completely different and nothing related to data volume or quantity

fpalero said:
Hi Christ,

And by the way :)

You can probably tell from my signature text, I am in no way affiliated with a possibly composite character from a well known work of fantasy fiction.

Chris.

Indifference will be the downfall of mankind, but who cares?
Time flies like an arrow, however, fruit flies like a banana.

Never mind this jesus character, stars had to die for me to live.
 
This works, but it's very specific to the text being removed starting with "Ext"...

Code:
$ echo '"C"|"ExtClaQYT64NF"|"20170110"|"ExtClaIPE46RT"' | [highlight #FCE94F]sed 's/Ext[^|]*"/"/g'[/highlight]
"C"|""|"20170110"|""

 
pipe it to:
Code:
awk -F'|' '{ printf "%s|\"\"|%s|%s\n", $1,$3,$4 }'
This is not sed though. I am not sure if using sed is a requirement.
 
Hi SamBones,

Working Great! many thanks for the help.

Hi Iggsterman,
Great awk working too. you guys make me happy solving my case. Thank you very much.

Regards,
FPalero
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top