INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Jobs

SED search word hugs of data and replace with blank

SED search word hugs of data and replace with blank

(OP)
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

RE: SED search word hugs of data and replace with blank

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.

RE: SED search word hugs of data and replace with blank

(OP)
Hi Christ,

Good Day!

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

Regards,
FPalero

RE: SED search word hugs of data and replace with blank

So;

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

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

Quote (fpalero)

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.

RE: SED search word hugs of data and replace with blank

This works, but it's very specific to the text being removed starting with "Ext"...

CODE

$ echo '"C"|"ExtClaQYT64NF"|"20170110"|"ExtClaIPE46RT"' | sed 's/Ext[^|]*"/"/g'
"C"|""|"20170110"|"" 

RE: SED search word hugs of data and replace with blank

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.

RE: SED search word hugs of data and replace with blank

(OP)
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

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Resources

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close