There are multiple ways you can assign a file content into a variable in shell.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
## Create a file cat << EOF > file.txt hello world EOF ## Assign the value of the file to a variable var1=`cat file.txt` echo $var1 var1=$(cat file.txt) echo $var1 var1=$( echo $var1 |