. Explain the following unexpected result:

$ whereis date
date: /bin/date ...
$ echo $PATH
.:/usr/local/bin:/usr/bin:/bin
$ cat > date
echo "This is my own version of date."
$ ./date
Fri May 22 11:45:49 PDT 2009

1 answer

I will annotate each statement for your information.

1.$ whereis date
date: /bin/date ...
2.$ echo $PATH
.:/usr/local/bin:/usr/bin:/bin
3.$ cat > date
echo "This is my own version of date."
4.$ ./date
Fri May 22 11:45:49 PDT 2009

Annotations for line:
1. "whereis date" tells us where the executable file "date" is located, according to the current $PATH value. The result tells us that the executable file "date" is found in /bin
2. echo $PATH
tells us what is the content of the $PATH environment parameter. Each path is separated by a colon ":".
3. "cat > date"
takes standard input (stdin) from the keyboard and put the keyed in content into a new file in the current directory called date. The input should be terminated by a control-d, which is not mentioned in the question.
The file "date" usually has a permission of 644 or 600 (depending on the computer implementation), which means that it is not executable.
4. ./date
attempts to execute the file ./date, but it is not executable (by default). Again, depending on the implementation of the system, it may return
"permission denied", or
possibly search for the next directory from the $PATH environment variable, which outputs the current date and time.
Similar Questions
  1. Principal - 6000Rate - 5% Effective Date - May 15 Maturity Date - November 1 Partial Payment Amount - $1500 Partial Payment Date
    1. answers icon 7 answers
  2. 1. The best thing to do when going out with someone new is to _____.A. Go to a private place B. Go on a group date C. Go
    1. answers icon 13 answers
  3. Which option shows an example of organization by cause and effect?(1 point)Responses The local author is available on the parade
    1. answers icon 1 answer
    1. answers icon 11 answers
more similar questions