代码之家  ›  专栏  ›  技术社区  ›  atline

为什么bash不能运行。out文件?

  •  0
  • atline  · 技术社区  · 6 年前

    使用 gcc a.c 可以获得输出二进制 a.out

    a、 c

    #include <stdio.h>
    
    int main(int argc, char* argv[])
    {
        printf("Hello world!\n");
        return 0;
    }
    

    1.bash shell下的next可以。

    $ file a.out
    a.out: 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]=6107be037f932892b69677f69b90a1d71b94e9e4, not stripped
    $ ./a.out
    Hello world!
    

    2.bash shell下的next不好。

    $ bash a.out
    a.out: a.out: cannot execute binary file
    

    以上两种有什么区别?

    bash xxx 梅可以执行这样的操作 a.sh ,这也许是答案,但是什么 $ ./a.out 当我在bash shell中运行它时,它似乎也在bash中运行?他们有什么不同?请帮我理解,谢谢。

    0 回复  |  直到 6 年前