# sh: how to echo line without escape processing



## monkeyboy (Oct 2, 2014)

I'm writing a shell script which processes a text file line by line and compares each line to string arguments passed down from the command line. Actually it is trying to solve the old problem of, if you have false hits in Procmail, how to you figure out which pattern is causing the problem?

The core of the script is something like this:

```
sed -n -e ...pattern to pull RE's from Procmail |   # pipe each Procmail RE into a while loop \
  while read line
  do
       echo "$*" | if grep -q "$line"
        then
                echo "HIT: $line"
       fi
  done
```

The script basically works, and I found the offending Procmail pattern. But I observed that the script is not quite right as
the construct "$line" used several times is doing escape processing and will remove backslashes, etc. How do I get
"$line" to not do any escape processing but keep the incoming line of text totally intact and unaltered?

edit: hmmm... on further examination, it may be the read line command instead that is discarding backslashes...
How do I do a read without escape processing?

it looks like read in some shells has a -r option which probably does the job...


----------



## monkeyboy (Oct 8, 2014)

gpatrick said:
			
		

> My shell scripting is almost entirely written in ksh.  This may be what you want:
> 
> 
> 
> ...


yes, but as it turns out, the problem is not with the "echo" but "read", so "read -r" solves the problem.


----------

