LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 08-06-2009, 11:55 AM   #1
super_bash
LQ Newbie
 
Registered: Aug 2009
Posts: 2

Rep: Reputation: 0
Bash escaping


Hello,

I having a problem reading a file in a while loop.
My file (called "testfile.txt") contains these lines:
\"test\"
\"hello\"

(including both \ and ")

This is the loop I have written:

=======================
while read line
do
echo $line
done < testfile.txt
=======================

the output is:
"test"
"hello"

it removes the slashes (which I need).

I also tried with:
echo ${line}
echo "$line"
echo "${line}"

without success.

It looks like I can't figure out the solution ... maybe I am too tired

Can anyone help me please?

Thank you!
 
Old 08-06-2009, 11:59 AM   #2
karamarisan
Member
 
Registered: Jul 2009
Location: Illinois, US
Distribution: Fedora 11
Posts: 374

Rep: Reputation: 55
According to `man read`, read takes a -r option. Try that.

You lose the escapes before they get to echo, by the way. That's why none of that other stuff worked.
 
Old 08-06-2009, 12:04 PM   #3
super_bash
LQ Newbie
 
Registered: Aug 2009
Posts: 2

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by karamarisan View Post
According to `man read`, read takes a -r option. Try that.

You lose the escapes before they get to echo, by the way. That's why none of that other stuff worked.
Thenk you karamarisan it works like a charm!

You saved my day!
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
filename escaping in bash dash9 Linux - Software 1 06-04-2009 10:36 PM
escaping bash shell hectorDUQUE Fedora 5 03-15-2008 06:04 AM
escaping ':' character in bash script paulyche Linux - General 2 11-07-2006 07:18 AM
Bash script - escaping whitespaces colabus Linux - Newbie 15 04-29-2006 11:58 PM
NOT escaping bash history ivanatora Linux - General 3 06-07-2005 01:17 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 02:20 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration