I'm behind on a Linux class project and struggling with shell scripting. I wrote a Bash script that should display the current date and time when I run the assigned command, but I keep getting a "command not found" error. I'm starting to feel like I'm just bad at scripting. What should I check?
2 Answers
For a script, make sure the file contains something like `#!/bin/bash` on the first line and `date` on the next. Then either run it with `bash filename.sh`, or make it executable with `chmod +x filename.sh` and run it as `./filename.sh`. If you type only the filename, the shell may not search the current directory and report that it can’t find the command.
You’re not dumb—you’re probably just still getting familiar with the shell. What exact command are you running, and what does the script contain? The full error message matters. If the script’s goal is simply to print the date and time, the basic command is `date`. You can read about its options with `man date`.

The last version I tried was supposed to show the date and time when I entered the assigned command, but the shell kept responding with "command not found."