Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I originally posted this at Stack Overflow but I thought it would be more appropriate here:

My LPT? printer (HP Deskjet 420) is indenting text when I print to it:

echo -e "this is text" > /dev/lp0
echo -e "moretext" > /dev/lp0
echo -e "also text" > /dev/lp0

Output:

this is text
            moretext
                    alsotext

How do I have each line be directly below the line before?

Using Lubuntu with bash.

share|improve this question

1 Answer 1

up vote 1 down vote accepted

To fix this problem, enable the newline (-n) flag when echoing text, and follow every command with

\n\r

What this does is the command makes a newline manually then prints a carriage return, which literally returns the print carriage to the beginning of the new line. Example bash code:

echo -e -n "this is text\n\r" > /dev/lp0
echo -e -n "moretext\n\r" > /dev/lp0
echo -e -n "also text\n\r" > /dev/lp0

Should print:

this is text
moretext
alsotext
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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