If I found a post that properly quotes code (gives attribution) from an original source, is it ok if I attribute to that post only, or do I need to give attribution to the original source?

For instance: I found this StackExchange answer: https://unix.stackexchange.com/a/4533/92787 :

Remove color codes (special characters) with sed

sed -r "s/\x1B\[([0-9]{1,2}(;[0-9]{1,2})?)?[m|K]//g"

Which properly links to the original source: http://www.commandlinefu.com/commands/view/3584/remove-color-codes-special-characters-with-sed

Is it ok if in my code I put only this:

# sed expression taken from https://unix.stackexchange.com/a/4533/92787
[my code] .... sed -r "s/\x1B\[([0-9]{1,2}(;[0-9]{1,2})?)?[m|K]//g" ... [my code]
  • 2
    What's the reson for not just referencing the original article? I'm saying you are taking the wrong approach, just curious as to your reasons.
    – David Arno
    Dec 4, 2015 at 11:21
  • @DavidArno No particular reason. It's not that I don't want to link to the original source, it's that since I find the post first, and sometimes that posts add something beside the original (context, explanation, usage example), plus that post properly links to the original, I just copy paste that posts's link. Idk, it's kind of a two birds, one stone...
    – bolov
    Dec 5, 2015 at 10:45
  • plus sometimes a post combines code from multiple sources. So it's a commodity thing, too, especially when it's about a small sample of code.
    – bolov
    Dec 5, 2015 at 10:50

1 Answer 1


Surely the IANAL answer is, it depends upon the licence of the original source, and how that may be adjusted by the licence of the attributing site :-(

If there are multiple attributions, I'd leave your example as is, perhaps adding which was from multiple sources allowing anyone to follow the link themselves to find the others.

For your exact example, of course, the simple adjustment is:

# sed expression taken from http://unix.stackexchange.com/a/4533/92787
# which obtained it from http://www.commandlinefu.com/commands/view/3584/remove-color-codes-special-characters-with-sed
[my code] .... sed -r "s/\x1B\[([0-9]{1,2}(;[0-9]{1,2})?)?[m|K]//g" ... [my code]

And if that's how you found it, it attributes both "sources".

Not the answer you're looking for? Browse other questions tagged or ask your own question.