I have a sample text file as shown below. I want to read the file and print each line on the terminal. I wrote a sample shell script test_sample.sh.
The directory containing the shell script and text file contain others files too. When I run the shell script. It works fine, but the command output is mixed with output of the files residing in the directory.
% ./test_sample.sh sample.txt
== abc ==
abc.txt readme.txt sample.txt test_sample.sh I have a car.
abc.txt readme.txt sample.txt test_sample.sh My car is clean.
Question is how do I get to print just the lines of the text file?
test_sample.sh
#!/bin/bash
fname=$1
while read p; do
echo $p
done < $fname
sample.txt
== abc ==
* I have a car.
* My car is clean.