Any printer which understands postscript or PCL can also understand raw text so perhaps, at its very simplest, you could do:
sed 's/$/\r/n' >/dev/usblp0
When run in a terminal, sed will read from the keyboard, convert \n into \r\n, and print it back out into /dev/usblp0.
When you're finished typing, hit control-D to tell sed the document is finished and to quit. You may not see any printing happen until you do, unless you have an old-fashioned tractor feed printer. Even for those, you won't see any printing until you finish a line with enter...
What I dont get is what do you mean by written text sent to printer...
The rest:
You put the desired sequence in a file, you send it to the printer ... then ? see above...
I would use an alias for setting the printer, like that you could have a few settings you would call before to print...
Sorry im not that good at explaning my self
I have a lp 2844 label printer and i have to print stickers out with a code on each of them for items that are going to be stored so i can keep track of them in an excel file
How do you usually use this printer? It may be proprietary app-specific, and may be easier to use it than try and write a whole printing system from scratch.
I think he means he wants a bash script which generates lots of similar labels, instead of a text file containing EPL2 commands which he edits by hand.
That's only the text to clear the buffer. What code would you actually use to print a label? And how do you usually send these codes to the printer?
In the future, please place source code and program output inside code tags when posting. It will prevent the problems you are having, like smilies appearing in the middle of your code.
[ code ] #!/bin/bash ... [ /code ] without the spaces in the tags and it will appear as
#!/bin/bash ...
It's even easier than you think to put two lines into a variable. Don't put in \n -- put in a real newline.
VARIABLE="line1
line2
line3"
Also, be sure to quote the variable when you use it, to prevent the shell from processing any of the whitespace.
echo $variable # This may convert newlines into spaces
echo "$variable" # this will not process the text inside, printing it raw