11

Is it OK to remove prompt strings which don't add anything to a question or answer, changing for example this:

 7:07AM 49 % cat t1 
a
b
c
c
d
f
g
 7:07AM 50 % cat t2 
h
i
j
k
l
m
n
 7:07AM 51 % paste t1 t2 
a       h
b       i
c       j
c       k
d       l
f       m
g       n

to this:

% cat t1 
a
b
c
c
d
f
g
% cat t2 
h
i
j
k
l
m
n
% paste t1 t2 
a       h
b       i
c       j
c       k
d       l
f       m
g       n

?

11

Sure, but don't do it automatically, as it could have some subtle significance. For example -- perhaps not the best example, since it is slightly redundant information, but I would still leave the prompt in on that one.

In other words, as long as you actually read the question to make sure it's definitely irrelevant (and leave it in if there is any doubt at all), then great.

  • Agreed. I'd say remove the user@host part of the prompt though, since it's identical across the board and (as far as I can tell) just noise. What do you think? – l0b0 Mar 7 '13 at 15:28
  • @l0b0 : Yeah that would be good. – goldilocks Mar 7 '13 at 15:37
  • OK, cleaned it up. – l0b0 Mar 7 '13 at 15:41
6

Hmmm, I've left it in on several of my answers, because I think it actually looks nicer with it in. And sometimes it is important (for example, when multiple machines are involved, or multiple users).

anthony@Zia:~$ ssh haruhi
⋮
anthony@Haruhi:~$ sudo -i
[sudo] password for anthony: 
root@Haruhi:~# 

Stripping out the user@host in that would make it much less clear.

And, really, I dislike editing the output in examples when not needed. I feel they should, as much as possible, reflect the output the person relying on the answer should actually expect to see. I agree some editing is needed (e.g., in my example above, I cut out the login message, and indicated it with ⋮, because its fairly long). But the user@host part of the prompt isn't that long, is easy to skip over, and doesn't make the post taller.

I'd also discourage people asking questions from removing output, except in the case of privacy, because the OP may not realize the line he/she is striking is actually important.

  • The cases where the extra 'noise' is useful are very rare. – tshepang Jun 8 '15 at 19:41
5

Yes, that makes it more readable. Go for it. (Maybe also put some whitespace between the commands?)

  • 1
    I'd leave the whitespace, since it would actually change the semantics in this case (as in, there's another newline at EOF). – l0b0 Mar 7 '13 at 15:30
  • 1
    Sorry, to clarify, command whitespace fine, but maybe something between each command so it's not a big scary preformatted block. – mattdm Mar 7 '13 at 18:42
1

I have also done that although I prefer to replace it with a

$

which in my experience reflects a more common character.

  • The reasonable rule is to keep the last non-blank character of the prompt string that was originally posted, be it %, $, or #. – Scott Aug 26 '15 at 6:27
  • @Scott, I agree. The prompt character indicates the shell in the example was probably csh. – RobertL Nov 2 '15 at 22:32

You must log in to answer this question.

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