sodhosdh sodhosdh - 5 months ago 15
Bash Question

Making shapes with vi editor linux

For an assignment, I'm trying to make a shell script in VIM that will print a triangle that looks like the following:

+
| \
| \
| \
| \
+-----


Here is my code in VIM:

echo'+
| \
| \
| \
| \
+----- '


However, instead of getting that as the output when I run the script, it outputs as the following:

VI output issue

Can anybody tell me what I'm doing wrong?

Answer

Try this

#!/bin/bash
echo '
     +
     | \
     |  \
     |   \
     |    \
     +----- '

just start it on the next line since you need spaces before the "+"

Comments