I am comfortable with AWK regular expressions and would like to use them in GNU find
. Searching find
's manpages I found there are two options called -regex
and -regextype
which seemed relevant.
So I tried the following to list all the files with prefix file
in my directory which looks like this
[Desktop/test]$ tree .
.
├── bar
├── file1.pdf
├── file2.pdf
├── file3.pdf
└── foo
0 directories, 5 files
[Desktop/test]$
The command
[Desktop/test]$ find . -type f -name "*.pdf"
./file3.pdf
./file2.pdf
./file1.pdf
works as expected.
But trying
find . -type f -regextype awk -regex "file"
gave me no output (or errors). Where am I going wrong in the second invocation?
NOTE
I am using the following version of find on my Linux Mint box
find (GNU findutils) 4.7.0-git Copyright (C) 2016 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later http://gnu.org/licenses/gpl.html. This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law.
Written by Eric B. Decker, James Youngman, and Kevin Dalley. Features enabled: D_TYPE O_NOFOLLOW(enabled) LEAF_OPTIMISATION FTS(FTS_CWDFD) CBO(level=2)