How to read the file content into a variable in one go? May 19, 2023 by Tarik Process the lines inside the loop instead of after it. If you really need the file in a variable: var=$(<file)