linux - 来自 KornShell 脚本的回显未在终端中显示

标签 linux shell unix scripting ksh

我有一个 KornShell (ksh) 脚本,它应该在从提示符运行后显示 echo

#!/bin/ksh

file="file_path"

if [ -s $file ]
    then
        echo "yes"
    else
        echo "no"
fi

但是,"is"或“否”并未显示。我在不同目录中有其他脚本,它们具有类似的 if 语句,可以正确输出到提示符。

有什么想法吗?

最佳答案

您需要执行 chmod +x example.kshchmod 0755 example.ksh 才能执行脚本。

KornShell (ksh) 脚本本身运行良好。

example.ksh:

#!/bin/ksh

file="file_path"

if [ -s $file ]
    then
        echo "yes"
    else
        echo "no"
fi

example.ksh 输出:

@:/tmp #chmod 0755 example.ksh
@:/tmp #ksh example.ksh
no

关于linux - 来自 KornShell 脚本的回显未在终端中显示,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21116773/

相关文章:

以符号开头的 Linux 目录文件夹

python - Jupyter 笔记本 : "RuntimeError: Permissions assignment failed for secure file: ... Got ' 0o160 0' instead of ' 0o060 0' "

bash - 使用 ./dot-slash 运行 shell 脚本

unix - 如何查看共享对象的内部属性?

linux - 无法从 Vagrant VM 更改文件所有权

node.js - 如何更改 npm ll 的输出格式?

bash - 如何使用 Bash 脚本中的密码运行 sftp 命令?

linux - cd 命令 : how to go back an unknown number of levels from current subdirectory to a particular parent directory (unix and dos)

linux - 创建期间的 Unix 文件权限

c++ - libmemleak 转储泄漏回溯时如何显示正确的回溯?