建立文件westos,初始为空文件
[root@localhost 桌面]# file westos
westos: empty
编辑内容"Hello westos",使用file查看文件,会发现是ASCII的纯文本(文件的解码方式为ASCII)
[root@localhost 桌面]# file westos
westos: ASCII text
重新编写文件内容:“#include <stdio.h>”,类型就发生了改变,变为C语言
[root@localhost 桌面]# file westos
westos: C source, ASCII text
再次重新编写,类型又改变,意为脚本
[root@localhost 桌面]# cat westos
#!/bin/bash
[root@localhost 桌面]# file westos
westos: Bourne-Again shell script, ASCII text executable
由此可见文件内容不一样,文件类型就会发生变化,可以用file来查看文件类型。