This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 8 months ago.
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
接受
或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
发布评论
评论(7)
从根路径查找
find / -name "index.html"
从当前路径查找
find 。 -名称“index.html”
Find from root path
find / -name "index.html"
Find from current path
find . -name "index.html"
下面的代码行将为您完成。
find / -name index.html
但是,在大多数 Linux 服务器上,您的文件将位于 /var/www 或用户目录文件夹 /home/(user) 中,具体取决于您的设置方式向上。如果您使用控制面板,它很可能位于您的用户文件夹下。
The below line of code would do it for you.
find / -name index.html
However, on most Linux servers, your files will be located in /var/www or in your user directory folder /home/(user) depending on how you have it set up. If you're using a control panel, most likely it'll be under your user folder.
试试这个(通过 shell):
或者:
用你对它所在目录的最佳猜测替换 /var,但避免从 / 开始
Try this (via a shell):
Or:
Replace /var with your best guess as to the directory it is in but avoid starting from /
解决方案:使用unix命令
find
正则表达式查询、文件类型、大小阈值、深度
子树、组、所有权、时间戳、修改/创建日期等维度。
或/不/和等等...
传统的公式将是:
简单示例
1.按名称查找 - 查找所有
包.json
来自我当前位置子树层次结构。2.按名称和类型查找 - 从所有文件系统中查找所有
node_modules
目录(从根层次结构开始)复杂示例:
更多有用的示例可以展示标志选项和运算符的强大功能:
3.正则表达式和文件类型 - 仅在我的应用程序位置查找所有 javascript 控制器变体名称(使用正则表达式)javascript 文件。
-type
f 表示与正则表达式相关的文件-name
到控制器字符串和破折号的任何变体与.js
4.深度 - 查找应用目录中的所有路线模式目录不超过3个维度 (app/../../ ..仅且不再更深)
-type
d 表示与正则表达式相关的目录-name
到路由字符串-max深度
的任何变体,使查找器专注于 3 个子树深度,而不再< code>5.文件大小、所有权和 OR 运算符 - 查找 root 所有权下名称为“sample”或“test”的所有文件大于1的用户兆和小于 5 兆。
-size
阈值,表示大于 (+) 和小于 (-) 之间的范围-user
表示文件所有者-or
运算符过滤两个正则表达式匹配的查询6.空文件 - 查找文件系统中的所有空目录
7.时间访问、修改和创建文件 - 查找所有创建/修改/访问的文件10 天内的目录
8.修改大小过滤器 - 查找一周前到三周前修改过且小于 500kb 的所有文件,并以列表形式显示其大小
Solution: Use unix command
find
regular expressions queries, file types, size thresholds, depths
dimensions in subtree, groups, ownership, timestamps , modification/creation date and more.
or/not/and etc...
The Traditional Formula would be :
Easy Examples
1.Find by Name - Find all
package.json
from my current location subtree hierarchy.2.Find by Name and Type - find all
node_modules
directories from ALL file system (starting from root hierarchy )Complex Examples:
More Useful examples which can demonstrate the power of flag options and operators:
3.Regex and File Type - Find all javascript controllers variation names (using regex) javascript Files only in my app location.
-type
f means file-name
related to regular expression to any variation of controller string and dash with.js
at the end4.Depth - Find all routes patterns directories in app directory no more than 3 dimensions ( app/../../.. only and no more deeper)
-type
d means directory-name
related to regular expression to any variation of route string-maxdepth
making the finder focusing on 3 subtree depth and no more<yourSearchlocation>/depth1/depth2/depth3
)5.File Size , Ownership and OR Operator - Find all files with names 'sample' or 'test' under ownership of root user that greater than 1 Mega and less than 5 Mega.
-size
threshold representing the range between more than (+) and less than (-)-user
representing the file owner-or
operator filters query for both regex matches6.Empty Files - find all empty directories in file system
7.Time Access, Modification and creation of files - find all files that were created/modified/access in directory in 10 days
8.Modification Size Filter - find all files that were modified exactly between a week ago to 3 weeks ago and less than 500kb and present their sizes as a list
查找 /the_path_you_want_to_find -name index.html
find /the_path_you_want_to_find -name index.html
一般来说,在任意位置查找任何文件的最佳方法是启动终端窗口并输入经典的 Unix 命令“find”:
因为您要查找的文件是 Web 根目录中的根文件服务器,可能更容易找到 Web 服务器的文档根目录。例如,查看:
/var/www/*
或键入:
In general, the best way to find any file in any arbitrary location is to start a terminal window and type in the classic Unix command "find":
Since the file you're looking for is the root file in the root directory of your web server, it's probably easier to find your web server's document root. For example, look under:
/var/www/*
Or type:
我们有2个选项,一个是find命令,另一个是locate命令
Find Command
如果您的文件是index.html
sudo find / -name index.html(如果您知道路径,请替换而不是/)
则需要sudo
如果您在根访问文件夹中搜索locate命令,
定位命令将保存单独的数据库来运行。
ex:
如果您的文件找不到, 请定位index.html
运行以下命令
sudo updateb
now 尝试定位index.html
注意:locate 更快,因为它使用 db 而不是直接文件系统搜索,
但从我的角度来看,find 命令很好,因为它搜索整个文件系统。
希望你能出点好主意。
There are 2 options we have, one is find command and another is locate command
Find Command
if your file is index.html
sudo find / -name index.html (if you know the path pls replace instead of /)
sudo is required if you are searching in root access folders
locate command
locate command will hold the separate db to run.
ex: locate index.html
if your file is not able to find
run the following command
sudo updatedb
now try to locate index.html
Note: locate is faster because it uses db instead of a direct file system search
But from my point of view find command is good, because it is searching the entire file system.
Hope you go some good idea.