My code is as below,

while IFS= read line
        # display $line or do somthing with $line
    echo $x
    # sleep 10

done <"$file"

However, this one gives me following result.


Any help is appreciated

  • Have you tried x="\'${line}\'" ?
    – perror
    Jul 19 '18 at 15:37

The escape characters are not needed for a single quote within double quotes. Double quotes already escape single quotes. Just use:

  • It gives me following out put 'google.com, it doesn't add quote around end
    – Kush Patel
    Jul 19 '18 at 15:37
  • @KppatelPatel: what are the contents of test.text?
    – jesse_b
    Jul 19 '18 at 15:38
  • file that is converted from CSV to text, each line is just url
    – Kush Patel
    Jul 19 '18 at 15:40
  • @KppatelPatel: I think you have a typo somewhere in your code that isn't displayed here than because it works fine for me.
    – jesse_b
    Jul 19 '18 at 15:44
  • It seems like something is wrong when I convert csv to text file, when I diligently copy data from file to another file, it worked.
    – Kush Patel
    Jul 19 '18 at 15:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.