I host a .md
file with a few Bash code lines in my GitHub account and would like to copy-paste these lines and execute them, one by one, to upgrade software (a website module) non automatically on purpose;
These Bash code lines work on a website directory which in my case is under:
$HOME/MEDIUM_DIRECTORY_1/DOMAIN_DIRECTORY/MEDIUM_DIRECTORY_2
.
I don't want to publish the actual path in GitHub so I seek how to interactively query the user (currently only myself but in the future not necessarily so) directly in the terminal, for such a path.
In my shared hosting environment, user names for SSH are very long and random such as jktantttopppazqqqddd
so it would be inefficient for me to memorize them or to copy-paste them from the terminal each time anew, but the rest of the path is easy for me to remember; this is why I wanted to prompt myself with "${HOME}"
as a variable expansion and then store it along with the rest of the path in a variable --- just before copy-pasting and executing the Bash code lines (with which I would utilize such a variable).
I tried to use something like read website_dir
and give the path above where ${HOME}
is a variable expansion as with "${HOME}"/MEDIUM_DIRECTORY_1/DOMAIN_DIRECTORY/MEDIUM_DIRECTORY_2
, but it wasn't fruitful because one cannot expand variables inside read.
I would define what I am trying to do as efficiently creating a path to work with before copy-pasting and executing commands from a file, in the terminal, one by one and I seek the most efficient way to achieve that which principally must include some automation in printing the long and randomly created username (without copy pasting it from terminal or from anywhere else, such as echo $HOME
).
How would you solve the problem of creating a path with the username automatically?
Update
This worked for me:
home_dir=$(echo $HOME) &&
read website_dir_relative_path_after_home_dir &&
website_dir="${home_dir}${website_dir_relative_path_after_home_dir}" # Note the lack of spacing between the two ${}${};
Please share how you would do it.