Find the answer to your Linux question:
Results 1 to 2 of 2
I need to read a text file line by line using bash. I have it working using the code below, but the problem is that when it won't read in ...
  1. #1
    Just Joined!
    Join Date
    Dec 2008
    Posts
    11

    Reading lines from text file in Bash

    I need to read a text file line by line using bash. I have it working using the code below, but the problem is that when it won't read in the backslash character (\). These get excluded if I echo the contents in the script or write them to a different file. Does anyone know how to get the backslashes to stay?

    Code:
    cat file.txt | while read line
            do
                            echo "$line"
            done

  2. #2
    Just Joined!
    Join Date
    Dec 2008
    Posts
    11
    Got it. Had to use the -r option for my read command to get the raw input.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
...