5

I am trying to read a file using Linux Bash and then use "grep" to run that line against the file itself. It seems not working to me...

#!/bin/bash

path=$1
while read line
do
    var1=$(grep $line $path)
    echo $?
    exit
done < $path

The $? returns 1. What's going on here?

4

1 回答 1

1

Use grep -F (fixed string) instead:

var1=$(grep -F "$line" "$path")
于 2013-08-28T21:07:24.270 回答