Terminal - command not found

2020-02-07 12:55发布

问题:

I'm trying to learn to write shell scripts and use the Terminal.

In Users/user/Development/linux I've got a script called sysinfo_page.

So I'm in the linux folder in the terminal and I can see the sysinfo_page when I type the ls command.

However, when I enter the following command:

sysinfo_page > sysinfo_page.html

I receive the following message:

-bash: sysinfo_page: command not found

How do I resolve this?

回答1:

If you want to run a script file form the current directory, you have to write ./ before your script name:

./script.sh


回答2:

Your command may not be an executable file. Try this:

chmod +x sysinfo_page
./sysinfo_page > sysinfo_page.html

The first line will set the eXecutable flag on the file, the second will run it from the current dir. Note that if you want to run a file in the current directory and that dir is not included in your PATH, you need to prepend ./ or else the shell won't find it.