My answer here was deleted as 'duplicate', with a link to the faq where is stated, that exact duplicates are removed, while the first part used a different syntax - compare yourself:

grep -E -H 'string1|string2|stringn' 
egrep "(string1|string2|string3)" 

which is a different syntax, and imho reason enough to be allowed. Let the user up- and downvote, and not moderators decide, which syntax to use. But ...

... but the second part of my answer is completely different from all other solutions:

grep pattern file{1..3}

compared to

grep pattern file1.txt file2.txt filen.txt
grep pattern file*.txt

They're different, just not in a way that particularly matters. egrep and grep -E are identical. You added a matching group around the strings, which doesn't do anything. And file{1..3} versus file1.txt file2.txt filen.txt or file*.txt really doesn't have anything to do with the question, it's just different ways of filename globbing.

I deleted a bunch of answers on that post because it came from SO and had a bunch of duplicates (a user flagged the question and pointed out all the overlap). If you want it undeleted I will, but I don't think it contributes anything the other answers don't already have

  • Why do you believe the couple of files are irrelevant in the context? The only difference between string1-n and file1-n I see, is, that string is mentioned first. Maybe it's only about grepping multiple strings, but why did AbraKdabra then mention the files, and emphasise them in a code block? And some people might prefer egrep over grep -E, some may prefer the other way, maybe most people aren't interested. I'm a friend of pluralism and free choice, and never saw such deletion before. I thought the up- and down-voting system is meant to find out what the most valuable posts are. – user unknown Apr 29 '11 at 0:19
  • 2
    @user You've never seen such deletion before because usually mods wouldn't leave a comment, they'd just kill it. Code blocks aren't for "emphasis", and anyway the author didn't include one originally, I added it when I formatted his post. I think you're reading too much into his particular example; he's got some strings, and he needs to search some files. The odds that he actually has exactly three files named "file1.txt", "file2.txt", "file3.txt" is pretty low – Michael Mrozek Apr 29 '11 at 0:35
  • 1
    It's pure speculation, but in many cases, you can change your work flow, if you know, there is a convenient way to address your files as file{1..999}.txt, you might name them this way in future. Did you think of it this way? I found this comment meta.unix.stackexchange.com/questions/578/… from Jeff Atwood, and don't like to invest some time in writing an answer, testing it, and lay it out, to have it deleted because somebody interpreted the question differently, and expects me to guess, what the minimum difference is, needed to ... – user unknown Apr 29 '11 at 0:48
  • ... justify an alternative answer. Please note, that I appreciate the pluralism of answers and voted 3 of the other answers up, because they teached me something new; well, two of them - the -f-option was new for me. – user unknown Apr 29 '11 at 0:52
  • 1
    @user I like a bunch of answers too, if they actually answer the question in different ways. The only thing your answer introduces is the file{1..3} syntax, which I still maintain has almost nothing to do with the question -- the filenames he provided were just an example. I undeleted your answer since you want it back so badly, but I still think it's a duplicate of other answers that were posted hours before – Michael Mrozek Apr 29 '11 at 1:59
  • Well, I thank you, and I still think there are two variations in my answer, and your impression, that the second is of no interest, is purely subjective - my impression differs. If you like to investigate my answers here, as well as in AU, SE, CR, CG and so on, I only write an answer, to introduce a new aspect. I never repeat postings just to write 'me too!' - au contraire, I hate postings which only repeat the same answer again, but of course, most of them are only minutes apart. – user unknown Apr 29 '11 at 3:49

Ok, the first answer is a slight variation of another answer and not an exact duplicate. But you could have suggested this slight variation in a comment. Your answer was adding very little value on that count.

The second part, file{1..3}, is a variation that's irrelevant in this context, and even wrong (file{1..3}.txt would have been better, but file*.txt is more likely to be useful).

That simple question already has 5 answers (plus 3 deleted), most of which closely resemble the others. That's more than enough!

  • Well, Gilles, your answer here about the missing '.txt' could have been a comment to my post, instead of deleting it. I can't ses other, deleted answers, so I don't see how my answer compares to them. Why do you believe the second part is irrelevant in the context? It was asked for it. And file* would match file-1.txt or file-foobar.txt which is a broader pattern than what the asker introduced, so it is you who is wrong here. – user unknown Apr 29 '11 at 0:13
  • Sorry - "it's you, who is wrong here, too. I would like to update my posting to say 'file{1..3}.txt, which was wrong, too.' – user unknown Apr 29 '11 at 0:23

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .