0

I have a text file that has something like this:

loginName:  Name1   userAgent:Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/ (KHTML like Gecko)  Chrome/61.0.3163.104    OpenFin/9.61.31.74
loginName:  Name2   userAgent:Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/ (KHTML like Gecko)  Chrome/61.0.3163.112
loginName:  Name3   userAgent:Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/ (KHTML like Gecko)  Chrome/61.0.3163.105    OpenFin/9.61.31.78
loginName:  Name4   userAgent:Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/ (KHTML like Gecko)  Chrome/61.0.3163.100

Some has only Chrome/X.X.X.X and others have Chrome/X.X.X.X OpenFin/X.X.X.X

The ones that only have Chrome/X.X.X.X, I want to leave them alone. The ones that include OpenFin/X.X.X.X, I want to remove Chrome/X.X.X.X from those lines.

I tried the following but had no luck.

sed 's/Chrome*.*OpenFin/OpenFin/' filename
0

It worked by modifying to the following:

sed 's/Chrome.*OpenFin/OpenFin/' filename

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.