|
|
|
|
|
by hnlmorg
3203 days ago
|
|
Some handy tips there but I would recommend changing some of the `find` examples: find . -exec echo {} \; # One file by line
You don't need to execute echo to do that as find will output by default anyway. There is also a `-print` flag if you wish to force `find` to output. find . -exec echo {} \+ # All in the same line
This is think is a dangerous example because any files with spaces will look like two files instead of one delimited by space.Lastly, in both the above examples you're returning files and directories rather than just files. If you wanted to exclude directories then use the `-type f` flag to specify files: find . -type f ...
(equally you could specify only directories with `-type d`)Other `find` tips I've found useful that might be worth adding: * You don't need to specify the source directory in GNU find (you do on FreeBSD et al) so if you're lazy then `find` will default to your working directory: find -type f -name "*.txt"
* You can do case insensitive named matches with `-iname` (this is also GNU specific): find -type f -iname "invoice*"
|
|
This was added to OpenBSD 17 years ago. Other BSDs soon followed. Solaris & IllumOS support it too.
http://cvsweb.openbsd.org/cgi-bin/cvsweb/src/usr.bin/find/op...