Tom-Oliver Heidel
Tom-Oliver Heidel

Reputation: 1131

Unix how to use 'command()' in bash

maybe this is a total noob question. But I do not know how to use this. For example when I have 'stat' I can use 'stat /home/'. But when I type stat() a new Line starting with '> ' comes up. Can anyone tell me what to do with that? I am just curious because there is lstat (man lstat) but I cannot use it - System won't find it. But there is lstat().

Maybe you can help me to resolve this or to ask the question some better. (Reformatting welcomed as well I know I suck in those things)

Edit: I noticed you can type anything before brackets and it will start with the new line I said above.

Upvotes: 0

Views: 45

Answers (2)

chepner
chepner

Reputation: 531075

Don't confuse a system call with an executable wrapper around that call. For instance, see man 2 stat for documentation about the system call named stat, and man 1 stat (or simply man stat) for documentation about the command stat that uses the system call to provide information about the requested files.

The shell does not provide direct access to system calls; its purpose is to run other programs.

When you type stat() at a shell prompt, you begin a shell function definition. The > indicates that the shell is waiting for the rest of the definition. For example:

$ foo()
> { echo hello; }
$ foo
hello

Upvotes: 1

Christopher Creutzig
Christopher Creutzig

Reputation: 8774

In bash, the syntax stat() starts the definition of a function called stat. You don't call functions that way in a shell, just use the same syntax as for commands defined on the path.

lstat is listed in the man page as lstat(2), meaning the man page is in section 2 of man pages. That section is for OS calls from a program, not for shell commands. Try checking out the SYNOPSIS part of a man page to see how to use things: If there is a #include line, you can be pretty sure it's for C programmers.

Upvotes: 1

Related Questions