re: Getting started with bash VIEW POST


You can use $USER instead of invoking another program, i.e. $(whoami). Similarly for $PWD. You can also use printf directly to print the date, check man strftime.

The printf command is really powerful and is more than an extension to echo. Note that the way you are using it may cause issues, as it concatenates the format and the variable(s) part:

printf 'FORMAT' $VALUE(S)

Or as an example:

printf 'You are here => %s\n' "$PWD"

You may also want to check out the short notation for the bash built-in test command [[ ]].


code of conduct - report abuse