发布于 2017-11-06 20:47:48
Mac有一个终端命令whereis,它给出了文件的位置。whereis python给出了python的位置。此外,which python还提供了当前的python代理版本。
发布于 2018-01-09 13:12:00
很可能您已经安装了它:
DESCRIPTION
The locate program searches a database for all pathnames which match the
specified pattern. The database is recomputed periodically (usually
weekly or daily), and contains the pathnames of all files which are pub-
licly accessible.
...
The locate program may fail to list some files that are present, or may
list files that have been removed from the system. This is because
locate only reports files that are present in the database, which is typ-
ically only regenerated once a week by the
/System/Library/LaunchDaemons/com.apple.locate.plist job. Use find(1) to
locate files that are of a more transitory nature.-从人的位置摘录
在这样的系统中:
OS, ker|rel, machine: Apple/BSD, Darwin 17.3.0, x86_64
Distribution : macOS 10.13.2 (17C88), High Sierra
bash GNU bash 3.2.57
locate - ( /usr/bin/locate, 2017-10-25 )请注意,定位报表与整个路径名匹配,因此可能会得到比预期更多的输出。我通常将输出输入到grep或grep中。
例如:
$ locate a.out生产:
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/share/man/man5/a.out.5
/Library/Developer/CommandLineTools/usr/share/man/man5/a.out.5
/Users/drl/try/confidence/lct-c/a.out
/Users/test1/try/confidence/lct-c/a.out
/usr/local/Homebrew/Library/Homebrew/test/support/fixtures/mach/a.out对于更长的列表,需要对其进行修剪,使用寻呼机等进行查看。
最美好的祝愿..。干杯,drl
发布于 2018-01-09 13:28:05
下面是一个Applescript,它递归地列出了带有选项的文件和文件夹。来源
property script_name : "List Folder Contents"
property script_description : "This script will list a folder's contents returning full paths as strings and limit the list to specific file types. The script can also process subfolders (recursion)."
set the_folder to (choose folder with prompt "Choose a Folder to List:") as Unicode text
set file_types to {} --file types, set to {} and inc_folders to true to just return folders; file types are 4 character codes such as "osas" or "TEXT"
set with_subfolders to my get_boolean("Search subfolders?", {"No", "Yes"})
if with_subfolders = "user cancelled" then return
set inc_folders to my get_boolean("Include folders in the list? (If you only want file names, and not folder names, select \"No\".)", {"No", "Yes"})
if inc_folders = "user cancelled" then return
set use_posix_path to my get_boolean("Return the paths as HFS (Mac-style) or POSIX (UNIX-style)?", {"HFS", "POSIX"})
if use_posix_path = "user cancelled" then return
set return_as_string to my get_boolean("Return the results as an AppleScript list or a string with each file on its own line?", {"List", "String"})
if return_as_string = "user cancelled" then return
set add_to_clipboard to my get_boolean("Copy the results to the clipboard?", {"No", "Yes"})
if add_to_clipboard = "user cancelled" then return
set the_files to get_folder_list(the_folder, file_types, with_subfolders, inc_folders, use_posix_path)
if return_as_string then
tell (a reference to my text item delimiters)
set {old_tid, contents} to {contents, return}
set {the_files_string, contents} to {the_files as Unicode text, old_tid}
end tell
copy the_files_string to the_files
end if
if add_to_clipboard then
if not return_as_string then
copy the_files to the_files_string
repeat with i from 1 to (count the_files_string)
set item i of the_files_string to ("\"" & item i of the_files_string & "\", ")
end repeat
set the_files_string to ("{" & (text 1 thru -3 of (the_files_string as Unicode text)) & "}")
end if
set the clipboard to the_files_string
end if
beep
return the_files
on get_folder_list(the_folder, file_types, with_subfolders, inc_folders, use_posix_path)
set the_files to {}
tell application "Finder" to set folder_list to items of folder the_folder
repeat with new_file in folder_list
try
set temp_file_type to file type of new_file
on error
set temp_file_type to "fold"
end try
if file_types contains temp_file_type or file_types = {} then
if use_posix_path then
set the_files to the_files & {POSIX path of (new_file as Unicode text)}
else
set the_files to the_files & {new_file as Unicode text}
end if
end if
if temp_file_type = "fold" then
if inc_folders and file_types ≠ {} then
if use_posix_path then
set the_files to the_files & {POSIX path of (new_file as Unicode text)}
else
set the_files to the_files & {new_file as Unicode text}
end if
end if
if with_subfolders then set the_files to the_files & my get_folder_list((new_file as Unicode text), file_types, with_subfolders, inc_folders, use_posix_path)
end if
end repeat
return the_files
end get_folder_list
on get_boolean(m, b)
try
return (button returned of (display dialog m buttons ({"Cancel"} & b) default button 3 with icon 1) = (b's item 2))
on error
return "user cancelled"
end try
end get_booleanhttps://softwarerecs.stackexchange.com/questions/46914
复制相似问题