sed

stream editor for filtering and transforming text

comment lines in a file with a # (or any other character that you need)

Result:

> echo -e 'test\ntest\ntest' > test
> cat test
test
test
test
> sed '1,$s/\(^.*$\)/#\1/' test
#test
#test
#test
> sed '2,$s/\(^.*$\)/#\1/' test
test
#test
#test
> sed '3,$s/\(^.*$\)/#\1/' test
test
test
#test