Answers:
是的,看来您的书是错误的。
该file命令告诉它是哪种文件。在手册文件中:“文件-确定文件类型”。
一些例子:
$ file /usr/bin/file
/usr/bin/file: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, for GNU/Linux 2.6.32, BuildID[sha1]=ecc4d67cf433d0682a5b7f3a08befc45e7d18057, stripped
$ file activemq-all-5.15.0.jar
activemq-all-5.15.0.jar: Java archive data (JAR)
该type命令用于告诉命令是内置的还是外部的:
$ type file
file is /usr/bin/file
$ type type
type is a shell builtin
type是大多数shell的内置函数,它告诉我们可以执行的操作是什么(内置函数,别名,函数,可执行文件等)。在您的情况下,这就是说没有test.sh可以执行的(在PATH中,或者作为内置/函数/别名等)。
file。我将更新我的答案。
文件类型通常由确定file。其man状态:
文件—确定文件类型
但是您也可以在一定程度上使用type。比较以下两个清单的内容:
script.pl,一个Perl脚本not_a_script,一个空文件这是脚本的一个:
$ ls
script.pl
$ file script.pl
script.pl: Perl script text executable
$ type script.pl
bash: type: script.pl: not found
$ type ./script.pl
./script.pl is ./script.pl
这是一个空文件:
$ ls not_a_script
not_a_script
$ file not_a_script
not_a_script: empty
$ type not_a_script
bash: type: not_a_script: not found
$ type ./not_a_script
bash: type: ./not_a_script: not found
如您所见,type可以确定文件是否可执行。那是“文件类型的确定”吗?好吧...与file提供的方式不同。typeBash的男人对buildin 的描述如下:
输入[-aftpP]名称[名称...]
如果没有选项,请指明如果用作命令名称,每个名称将如何解释。
在我看来file,书中问题的正确答案应该是我认为的,因为这就是它man所说的,这就是通过测试的意思。换句话说,我的首选是file。