greycat 1279726143 learn To read a file's contents into a variable: var=$(< file) However, this strips trailing newlines. To work around that: var=$(cat file; printf x) var=${var%x} izabera 1426810020 forget izabera 1426810052 learn To read a file's contents into a variable: var=$(< file) However, this strips trailing newlines. To work around that: var=$(cat file; printf x) var=${var%x} In bash 4.1 and above, read -rN0 < file greycat 1557761469 forget greycat 1557761470 learn To read a file's contents into a variable: var=$(< file); However, this strips trailing newlines. To work around that: var=$(cat file; printf x) var=${var%x}