Use Bash to read the file, then do grep with Line Against The File Itself

I am trying to read a file using Linux Bash, and then use grep to run this line against the file itself. It doesn't seem to suit me ...

#!/bin/bash path=$1 while read line do var1=$(grep $line $path) echo $? exit done < $path 

$? returns 1. What is going on here?

+4
source share
1 answer

Use grep -F (fixed line) instead:

 var1=$(grep -F "$line" "$path") 
+1
source

Source: https://habr.com/ru/post/1499488/


All Articles