How can i use any bash command in bash function

92 Views Asked by At

I am trying to use ls , cat etc commands inside a bash function

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

I am getting ls: command not found error when I run the function

Is it not possible to use bash commands inside bash function?

I could see examples where only echo is used inside the function

1

There are 1 best solutions below

2
Ashok On

When calling a function in bash, you shouldn't use the parentheses

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