首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >是否支持locate/grep命令?

是否支持locate/grep命令?
EN

Stack Overflow用户
提问于 2021-09-26 12:03:19
回答 2查看 253关注 0票数 0

如果docker支持我在ubuntu中使用的命令:

代码语言:javascript
复制
locate filename

代码语言:javascript
复制
grep -Hrn  -A 5 'search text' --include="*.php"  /DirectoryPath/

如果是,我如何安装它们?

在我的中添加命令之后,更新了#2 :

代码语言:javascript
复制
RUN apt-get install -y grep mlocate

我可以运行命令:

代码语言:javascript
复制
grep -Hrn  -A 5 'var' --include="*.conf"  /var/www

与有效的结果,但错误与定位:

代码语言:javascript
复制
root@11ed27f97ac4:/var/www# locate -help
Usage: locate [OPTION]... [PATTERN]...
Search for entries in a mlocate database.

  -A, --all              only print entries that match all patterns
  -b, --basename         match only the base name of path names
  -c, --count            only print number of found entries
  -d, --database DBPATH  use DBPATH instead of default database (which is
                         /var/lib/mlocate/mlocate.db)
  -e, --existing         only print entries for currently existing files
  -L, --follow           follow trailing symbolic links when checking file
                         existence (default)
  -h, --help             print this help
  -i, --ignore-case      ignore case distinctions when matching patterns
  -l, --limit, -n LIMIT  limit output (or counting) to LIMIT entries
  -m, --mmap             ignored, for backward compatibility
  -P, --nofollow, -H     don't follow trailing symbolic links when checking file
                         existence
  -0, --null             separate entries with NUL on output
  -S, --statistics       don't search for entries, print statistics about each
                         used database
  -q, --quiet            report no error messages about reading databases
  -r, --regexp REGEXP    search for basic regexp REGEXP instead of patterns
      --regex            patterns are extended regexps
  -s, --stdio            ignored, for backward compatibility
  -V, --version          print version information
  -w, --wholename        match whole path name (default)

Report bugs to mitr@redhat.com.
root@11d2e77af9c4:/var/www# mlocate -i error.log 
mlocate: can not stat () `/var/lib/mlocate/mlocate.db': No such file or directory

为什么在最后一行出错?好像我用了有效的语法?

提前感谢!

EN

回答 2

Stack Overflow用户

发布于 2021-09-26 12:08:06

在您的docker文件中,必须添加以下命令:

代码语言:javascript
复制
RUN apt install -y grep mlocate
票数 1
EN

Stack Overflow用户

发布于 2022-02-16 18:46:23

在运行“定位”之前将其添加到您的Dockerfile中

代码语言:javascript
复制
RUN /etc/cron.daily/mlocate
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/69334719

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档