3

I am having a file :

[email protected]
[email protected]
[email protected]
//[email protected]
//[email protected]
//[email protected]
[email protected]
[email protected]
[email protected]

I want to write a script which parse the file and for the first occurrence of say abc@gmail it should remain as it is and for other occurrence if "//" found then ok otherwise add "//" at the starting of all other occurrence.

3

1 Answer 1

2

You can use this awk command:

awk '$1 in seen && !/^[[:blank:]]*\/\// { $0 = "//" $0 } !seen[$1]++{} 1' file
[email protected]
[email protected]
[email protected]
//[email protected]
//[email protected]
//[email protected]
//[email protected]
//[email protected]
//[email protected]
Sign up to request clarification or add additional context in comments.

2 Comments

thanks anubhava ..... i would request you to help me in learning shell script i know a few basics but for complex things i just need google or platform like stackoverflow... could you please suggest any tutorials or books which i can refer...Thank you so much..
I just search good tutorials online. Start with this one

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.