Question 8 of the Linux Bash Prompt Lab asks to update Bob’s prompt so that it displays the date in the following format:
Example:
[Wed Apr 22]bob@caleston-lp10:~$
Solution: The following command works as expected:
echo 'export PS1="[\d]\u@\h:\w$"' >> ~/.profile
This successfully updates the prompt to display the date (\d), username (\u), hostname (\h), the working directory (\w) and the prompt symbol: $ for regular users and # for the root user.
And the change is made persistent.
However, this alternate solution does not seem to be accepted:
echo 'export PS1="[\d]\u@\h:\w\$"' >> ~/.profile
Possibly due to the separate use of \w and \$. The earlier solution combined these into a single command string.
Could you clarify why the second approach with the separate \w and \$ does not work and suggest any adjustments?