Reading Files Without "cat"
while IFS= read -r line; do echo "$line"; done < filename.txt
In this command:
while IFS= read -r line;: This loop reads the file line by line.IFS=(Internal Field Separator) ensures that whitespace at the beginning and end of lines is preserved. The-rprevents backslash characters from being interpreted as escape characters.do echo "$line";: For each line read from the file,echois used to print the line to the terminal.< filename.txt: Redirects the contents of the filefilename.txtto thewhileloop.
This command can be run directly in the terminal to read and display the contents of a specified .txt file.