Hi everybody, I am new to shell script. Please help me with this problem.
I have a file test.txt with the content like this:

! ((x5 * -1/3000) = x6)
((x5 * -1/2000) = x6)

I have a shell script test.sh like this

#!/bin/sh 

while read line
do    
    echo $line >> out.txt
done < test.txt

out.txt is expected to have the same content with test.txt. But here is the output.txt

! ((x5 laconfirm remote1 test.sh test.txt -1/3000) = x6)
((x5 laconfirm out.txt remote1 test.sh test.txt -1/2000) = x6)

laconfirm remote1 test.sh test.txt are files in the same folder.
It replaces the * in the original text.txt

Would you please tell me what is my problem and how I can fix it?
Thanks in advance.

Recommended Answers

All 2 Replies

As you noticed, a naked * is expanded to the contents of the directory. Inside the double quotes the globbing is suppressed:

echo "$line"
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.