Paul F. answered 06/24/20
Tutor
4.9
(11)
IT Consultant with over 20 years UNIX administration and scripting
If you are using sh as your shell, the best way to load an entire file into one variable is this simple assignment:
$ whole_file=`cat myfile.txt`
In bash shell, you also can use the following substitution construct:
$ whole_file=$(< myfile.txt)