Problem with including an "image" in shell program
I'm writing a program where at some point in my loop I want to print to output whatever is stored in a separate file (an image). But if I 开发者_如何学Ccode it like this:
for c in $LIST
do
clear
./image.0
done
And the "image.0" file contains only an image like this:
+----+
| |
|
|
|
|
|
========
Then when I run my program I get this message:
./image.0: 1: +----+: not found
./image.0: 2: Syntax error: "|" unexpected
Why?
================================
So "cat" works, the image appears in the output but it's shifted in a strange way. Do you know why this would happen?
+----+
| |
|
|
|
|
|
========
Answer: I put printf "\n" that fixed the shifting image
With ./image.0
, you tell the shell to execute the image. You want to output it, so use cat image.0
Try to use the command cat
to output the content of the image.0
file
cat ./image.0
./something
will take something
as a program and execute it. That's not what you want : to display the contents of a file, you can use the cat
command, like this :
for c in $LIST
do
clear
cat image.0
done
精彩评论