0

I have this code to print a horizontal line using unicode character \u2501:

#!/bin/tcsh
set horz_line = "'"
foreach x (`seq 1 1 80`)
   set horz_line = "${horz_line}\\u2501"
end
set horz_line = "${horz_line}\\n'"
printf $horz_line

But it is not giving what I expected. I expect the output to look like the one generated by below:

#!/bin/tcsh
foreach x (`seq 1 1 79`)
   printf '\u2501'
end
printf '\u2501\n'

The reason why I want to try out the code in the first block is because the code in second block works but is slow. When I run the second block code, I can see the whole line being drawn couple of characters at a time.

My thinking was that that's probably because printf is called 80 times. So I am trying out the first block approach where I generate a string of \u2501\u2501.. (80 times) and call printf just one to print that.

1 Answer 1

1

The following gets what I want in the first code block in the question. It is significantly faster than the second code block.

#!/bin/tcsh
set horz_line = ""
foreach x (`seq 1 1 80`)
    set horz_line = ${horz_line}'\\u2550' # double line
end
printf "`echo $horz_line`\n"
unset horz_line
1
  • Good find! For me it had to be one backslash: check="\u2718" then later printf "`echo -e $check`" Aug 8, 2019 at 13:20

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .