[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Wierd script treatment of asterisk in a line



Hello list!  I've got a simple shell question that I can't figure out.
I wrote a simple 3 line bash script designed to read from stdin and
output the lines to stdout that looks like the following:

--------------script.sh------------
#!/bin/bash

while read LINE; do
 echo $LINE
done
----------------------------------

I also have a single line text file ending with an asterisk (*) that
looks like this:

-----------------file.txt----------------
A Line in a file with spaces and ending with an asterisk *
-----------------------------------------


when I redirect the file to the script in any directory the script
outputs the line, but replaces the asterisk with the files in the
current directory like this:

jose@sweety:~/Desktop/test$ ./script.sh < file.txt
A Line in a file with spaces and ending with an asterisk file.txt script.sh

It even happens if I type the line in without redirection:

jose@sweety:~/Desktop/test$ ./script.sh
A Line ending with an asterisk *
A Line ending with an asterisk file.txt script.sh

Would someone know how I can make the script treat the asterisk as a
character belonging to the line and not a "match" for files in the
current directory?  Really appreciate it.  Thanks.

--
Sincerely
Jose Alburquerque



Reply to: