13

In this question, Command to display an arbitrary message if a particular file exists, Byte Commander and I answered within a few minutes of each other, with very similar answers. The main differences being that his example uses [ while mine uses [[, and we suggested different conditional tests but both referenced the other useful test options. I also included a link to a useful resource on using conditionals in Bash for the 'teach a man to fish' factor.

To be honest, it was a fairly quick answer, that I bashed out before leaving the house. Byte Commander's answer was accepted, which is fair enough, you can only accept one answer.

I've been surprised by the difference in votes, for essentially the same answer. I'm not moaning about not getting my rep (well maybe a little! * tear drops into coffee*), but a bit of advice about what I should have done differently would be useful.

Or is this just one of those luck of the draw situations?

4
  • 3
    Seems to me you just got unlucky. And isn't [[ ]] preferable to [ ]?
    – edwinksl
    Commented Jun 15, 2016 at 8:49
  • 1
    U definitely prefer [[ ]]! chalk it down to experience I guess.
    – Arronical
    Commented Jun 15, 2016 at 8:55
  • 7
    I think you may just be a victim of bad luck. Perhaps the other answer was on top when posted and some people did not read the rest of the page? The other answer does (slightly) have more detail in it,. people who voted only for one answer voted for that one. As discussed recently on meta, though we like to think it does not happen, there may be some "This user has 10k+, they must be right!" style votes on the other answer. As votes are anonymous and people don't leave +1 comments, it is hard to say. All I can do is think up some possible reasons, I don't think there is anything you did wrong.
    – Mark Kirby
    Commented Jun 15, 2016 at 8:56
  • 2
    Interesting question and I like all current answers, but JacobVlijm's one mentions the effective point I experienced it, Your post would be like a real poster. The other point is simplicity (top left part should be resumed and let user get what he wants quickly) see this related posts from SE Meta How do I write a good title? , How do I write a good answer to a question? , Style guide for questions and answers
    – user.dz
    Commented Jun 17, 2016 at 4:59

3 Answers 3

13

Just a few notes on "marketing" your answer

Both answers are fine, but:

...the decision to look into an answer is often done in a split second, and on a sub conscious level. Assume we are lazy readers (which I am), then the line:

Use this simple Bash one-liner:

...has a clear instruction, inviting to go on reading, while:

In the bash shell on the command line

asks me to think, bash shell? command line?

This may sound ridiculous, but those who ever discussed with Google how to make an advertisement know this is true.

As a rule

  • First of all, make sure to drop the solution into the reader's mind at first sight, preferably in a visible way, if that is impossible, be smart on using text to achieve the same.

Only then:

  • Once the reader likes the solution, start explaining how to use, and subsequently, for the real interested:
  • Explain why it works how it works, and why it is a good answer in your opinion.

Also note

  • A good answer can, and most likely will attract votes over time. Some answers, I've seen "on zero" for months, but got over 15 votes after a longer period of time..
  • The votes on an answer are not always a rational thing. I love the votes in this one (on which I deliberately refused an edit which added a header, for the reasons I mentioned above), but this one, I am still proud off however.

The voting on these answers does not have any relation with their quality.

Don't take votes in an absolute sense per question. It's just an indication on an average level, on a small area.

5
  • 3
    I'd never thought of it like a marketing exercise, but it makes a lot of sense to do so. I suppose my viewpoint was a purely functional or technical one. Good points.
    – Arronical
    Commented Jun 15, 2016 at 13:57
  • 1
    I actually never thought about marketing strategies when writing answers, but now that you say it, it seems like I usually follow most of them intuitively :)
    – Byte Commander Mod
    Commented Jun 16, 2016 at 21:27
  • «I've seen "on zero" for months» Coincidentally, I recently got a badge for having many zero-votes accepted answers and I was wondering what's wrong with my answers. :D Commented Jun 27, 2016 at 21:04
  • 1
    @AndreaLazzarotto Most likely, that means you are answering questions from 1 rep users, which is an honorable thing. Many people leave those questions, unsure about the possible (non-) responsiveness of the new posters :). Probably nothing wrong with the answers, but the posters aren't yet able to upvote. Commented Jun 27, 2016 at 21:21
  • @JacobVlijm oh mine, I didn't know that 1 rep users couldn't upvote. I do not remember the first site I entered here (maybe it's AU), but on all the sites I joined recently I always started with 100 rep "because we trust you on other sites of this network" hence I didn't think about troubles in upvoting. Commented Jun 28, 2016 at 10:09
11

You can make technical arguments between [ ] and [[ ]], and if you spend long enough in the dark crevices of the internet —as I have— you'll meet somebody claiming one of those is the most important factor to the price of fish.

Simple truth is it probably isn't that important for the stuff you're dealing with here. Especially not here on Ask Ubuntu where Bash is implicit and we don't have to pander to pure POSIX. I'm sure there are scenarios where using the command/builtin is more useful, but if they were relevant, there probably wouldn't also be a keyword version.

Timing can and luck are factors too. Even two identical answers posted at exactly the same time can see different vote patterns. And once one has the lead (or an accepted) it's going to show higher up the page.

To have any hope of reversing that you have to make your answer technically better.

1
  • 2
    Yeah I figured the [[ vs [ wasn't that important in this case, which is why I didn't defend using them very strongly in comments. It's just what I default to using, and understand more thoroughly. It's like quoting the echo string, which wasn't necessary here, but I tend to do as a safeguard.
    – Arronical
    Commented Jun 15, 2016 at 9:49
8

Just to clarify the exact situation when I posted my answer:

Yours did only use the -f operator and the answer lacked any explanation as well as did not have that link yet.

In the bash shell on the command line.

if [[ -f /path/to/file ]]; then echo "Yes"; fi

Then I posted my answer using -e and explaining why I chose that one, but respecting that your answer was a minute or so quicker and giving you credits for the -f part.

If you only want to check regular files, use -f instead, as @Arronical said.

My answer did not get edited afterwards, but you changed yours to include said -e vs. -f explanation and the link. At this point you also got my upvote btw.

I hope this helps you to understand why I posted my answer in the first place.


About why my answer is surprisingly so much higher rated? I don't really know.

Maybe because my command with single [] and without quotes around "Yes" looks simpler (although yours is probably better practice)? People tend to prefer simple looking stuff.

Another possible reason is the other, rather long answer which is on #2 now. As soon as it caught up with yours, people had to scroll down a "long" way to get to see your answer. People are lazy. This might explain why my answer continued receiving votes later and yours didn't, making the difference larger.

1
  • 3
    Oh I wasn't in any way rubbishing your answer, I thought it was totally legitimate, and not in any way ripping mine off. I was just wondering if I should have done something better. When I edited my answer it was actually at +2 and yours at +1, then I upvoted you too :)
    – Arronical
    Commented Jun 15, 2016 at 9:46

You must log in to answer this question.

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