Search notes:

Shell: find regex's stored in a file with grep -f

grep -f regexp.txt data.csv finds lines that are stored in the data.csv that match the regular expressions that are stored in the file regexp.txt.
grep -f is the abbreviation for grep --file.

Example

The use of grep -f is demonstrated in the following simple example.
This is data.csv, the file in which we want to search for regular expressions:
abc;42;foo
def ghi;999;bar
jkl;18;baz
barbarossa;33;qux
Github repository shell-commands, path: /grep/f-regular-expressions-in-file/data.csv
This is regexp.txt, the file that contains the regular expressions. Each regular expression occupies one line:
[[:digit:]]\{3\}
ro..a
Github repository shell-commands, path: /grep/f-regular-expressions-in-file/regexp.txt
Executing grep -f regexp.txt data.csv prints the two lines that match the regular expressions stored in regexp.txt:
def ghi;999;bar
barbarossa;33;qux

See also

Shell commands

Index

Fatal error: Uncaught PDOException: SQLSTATE[HY000]: General error: 8 attempt to write a readonly database in /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php:78 Stack trace: #0 /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php(78): PDOStatement->execute(Array) #1 /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php(30): insert_webrequest_('/notes/Linux/sh...', 1759612601, '216.73.216.149', 'Mozilla/5.0 App...', NULL) #2 /home/httpd/vhosts/renenyffenegger.ch/httpsdocs/notes/Linux/shell/commands/grep/f(63): insert_webrequest() #3 {main} thrown in /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php on line 78