0

The purpose in the example is to delete the rest of the string for each line after the pattern 90000: is found

Input file

generation
122344
41572:47149-47999/2(14485-14910) 41584:47149-47999/2(14911-15449) 90000:47919-47999/2(15447-15477) 90002:47919-47999/2(15478-15418) 
41548:48094-48894/2(12844-14244) 41590:48094-48894/2(14244-14944) 41572:48094-48894/2(14945-14045) 41584:48094-48894/2(14049-14449) 90000:48094-48114/2(14447-14447) 90002:48094-48114/2(14448-14458) 
12345

I tried . This code delete only some part of the text.. The purpose is to delete all characters after finds 90000:

sed 's/90000:*//' file

Desired output

generation
122344
41572:47149-47999/2(14485-14910) 41584:47149-47999/2(14911-15449)
41548:48094-48894/2(12844-14244) 41590:48094-48894/2(14244-14944) 41572:48094-48894/2(14945-14045) 41584:48094-48894/2(14049-14449)
12345

Appreciate your support

3

1 Answer 1

2

Could you please try following.

awk '{gsub(/ 9000.*/,"")} 1'  Input_file

To fix your code try:

sed 's/90000:.*//'  Input_file
Sign up to request clarification or add additional context in comments.

2 Comments

RavinderSingh13, awk '{gsub(/90000:.*/,"")} 1' Input_file . I think is better to match exactly with the pattern, otherwise it will delete all if found " 9000"
@OXXO, I believe that is what you needed right? It is giving expected sample output as per post.

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.