一个诡异的bash问题

一个诡异的bash问题

今天写的一个bash脚本运行发现:
test.sh: 1: #!/bin/bash: not found

本以为是由于在windows下编辑导致的问题,执行dos2unix之后问题依旧。

后来想到用file命令查看,文件居然是UTF-8 Unicode (with BOM) text格式

# file test.sh
test.sh: UTF-8 Unicode (with BOM) text

而正常的bash脚本格式应该为 Bourne-Again shell script text executable

用vim -b test.sh删除开头的<feff>即可。

原文地址:https://www.cnblogs.com/feisky/p/2468058.html