With Perl:
perl -lne 'print if /string1|string2|string3/;' file1 file2 *.fileext
With Bash, one liner:
while read line; do if [[ $line =~ string1|string2 ]]; then echo $line; fi; done < file
With Bash script:
#!/bin/bash while read line do if [[ $line =~ string1|string2|string3 ]]; then echo $line fi done < file
Note that all spaces around "[[$ line = ~ string1 | string2]]" matter. those. they do not work in bash:
[[ $line=~string1|string2 ]] # will be alway true... [[$line =~ string1|string2]] # syntax error
source share