Terminal - command not found

2020-02-07 12:59发布

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?

2条回答
放荡不羁爱自由
2楼-- · 2020-02-07 13:09

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

./script.sh
查看更多
三岁会撩人
3楼-- · 2020-02-07 13:22

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.

查看更多
登录 后发表回答