我如何在bash函数中使用任何bash命令

问题描述 投票:0回答:1

我正在尝试在 bash 函数中使用 ls 、 cat 等命令

Report()
{
    ls $1 |  sort -u
}
Report()

当我运行该函数时,出现 ls: command not found 错误

是否无法在 bash 函数中使用 bash 命令?

我可以看到函数内部仅使用 echo 的示例

bash function shell cat ls
1个回答
0
投票

在 bash 中调用函数时,不应使用括号

Report()
{
    ls $1 |  sort -u
};
Report;
© www.soinside.com 2019 - 2024. All rights reserved.