0
#!/bin/bash

while read p
do
  echo "$p"
done < numbers.txt

This script is only reading and allowing me to print .sh files. I have tried it with .txt files (like above but it does not print anything.)

1 Answers1

0

That's because you are printing test not variable p Try this:

#!/bin/bash

while read p
do
  echo "$p"
done < numbers.txt

Test:

$ cat numbers.txt
1
2
345
678
9
$ bash script.sh
1
2
345
678
9
$
Matej
  • 311
  • my apologies. I forgot to edit that ou, I was just testing something there. But even when changing to echo "$p", nothing prints – Cesa Salaam Feb 18 '19 at 19:24
  • @CesaSalaam It works for me, are you sure that numbers.txt file is not empty? – Matej Feb 18 '19 at 19:27