bash - 运行 shell 脚本时为 "command not found"

标签 bash shell unix

这是我拥有的简单 script.sh 文件:

#!/bin/bash
pwd
date
ls -lg

我使用 chmod +x 使文件可执行,但是当使用 ./script.sh 运行它时,我得到 command not found: pwd command not found: date 并且只有 ls -lg 命令有效。我对为什么前两个命令不起作用感到有点困惑,因为当我将它们输入命令终端时,它们会按应有的方式工作。

最佳答案

也不要使用名为 PATH 的变量(因为它已经被使用了:)

关于bash - 运行 shell 脚本时为 "command not found",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43771597/

相关文章:

bash - LINES 和 COLUMNS 环境变量在脚本中丢失

linux - 如何找到一个接受一个或多个参数并为每个参数输出一行命名 UTF-8 文件的 shell 脚本?

bash - 如何在 Bash 参数中保留引号?

c++ - 从 C++ 程序运行 shell 脚本会自动将 shell 脚本的输出显示到控制台吗?

java - 如何通过java运行带参数的shell脚本

linux - 使用awk和grep相加

sql - 从以 root 身份运行的 shell 脚本以 oracle 用户身份运行 oracle 脚本

c - 存档文件中的数字是什么意思?

linux - Systemd ExecStart 中的 Bash 大括号扩展

Linux脚本按行中的日期时间模式过滤文本文件中的行