Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

when i execute the following line, its prints the words in newline. awk 'BEGIN { print "line one\nline two\nline three" }' like line one line two line three

How can i print the info in the same line with flush the existing line. For example, while executing the loop, it should print 'one' then wipe out the line and prints 'two' then wipe out the line and prints 'three' etc. can you please assist me?

share|improve this question

Use carriage return instead of newline

awk 'BEGIN { print "line one\rline two\rline three" }' 

If a subsequent line is shorter than a previous line, you can print spaces to wipe out the remainder:

awk 'BEGIN { print "this is a long line of text\rpad with spaces            " }' 

If you are using separate statements, then you should use printf instead of print.

share|improve this answer

What environment are you using to view your output? Putty? You may need to reconfigure Putty to honor \n "newLines". OR if your really in Windows/DOS mode, you need

printf "line 1\r\nline 2\r\nline 3\r\n"

Hope this helps.

As you're a new user, just a gentle reminder to accept the answer that works for you, or at least add a vote to answers that help you're understanding.

share|improve this answer

Your Answer


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.