Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

3
  • Why do you have nested for loops? You loop over the whole file and then loop again over the file for each element. Get rid of those inner for loops. Commented May 2, 2022 at 7:37
  • @Philippos I used for loop to filter the data, actually what I want if case matches it should run command for all the strings which contains that string and other alphanumeric characters i.e events_0 to events_6 only once, not sure how I can achieve that in case and for loop. Commented May 2, 2022 at 7:42
  • "but it prints value multiple time since I have used case here" -- um, no, it's not because you're using case, but because you're explicitly grepping through the whole file for every matching word. I don't really see what the case is supposed to do anyway, since you could just run grep -e system-events_ new.txt >> polo.txt etc. The grep would just print an empty output if it didn't match anything. Commented May 2, 2022 at 10:18