Even if I type $aaa on UNIX, -bash:aaa:command not found

Asked 2 years ago, Updated 2 years ago, 86 views

-bash:aaa:command not found when typing $aa in the Getting Started UNIX shell programming.
#!/bin/sht is the default setting?
The operating system is a Mac.

macos unix

2022-09-29 20:26

1 Answers

To run a shell script, you must specify where the program resides.
If you put it somewhere other than the directory contained in the environment variable PATH, you must specify the program in the absolute or relative path.

"The ""aaa"" we created this time is in the current directory, so you can specify the following to run it:

$./aaa

As a supplement, after you create a program (shell script), you must first have chmod to execute it.

$chmod+xaaa

Additionally, #!/bin/sh should not be entered directly from the terminal, but should be written to the file using a text editor (for this example, create a file called "aaa" and put it in it).


2022-09-29 20:26

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.