In CentOS with Bash I download a file with a very trivial file name, install.sh
.
Although extremely unlikely in my scenario, this could still, in theory, overwrite some existing file with the same name.
How would you solve this problem?
If I understood correctly, one way to deal with this is:
cd DOWNLOADS &&
source <( wget --quiet -O - 'URL/install.sh' )
But as a non professional sysadmin I seek a more "basic" or "simple" way because I am having hard time working with the <(...)
syntax, let along with downloading to stdout with various options.
I was thinking about:
- Download a file with a randomly created long file name
- Do action with the file (such as
cp
andmv
to change name) - delete the downloaded file
Perhaps something like this pseudocode:
random_name=(wget -O kjghfkjdhsgkj.sh URL) # How to create random name by the computer?
destination=(cp "${random_name}" DESTINATION)
mv "${destination}" NEW_DESTINATION
rm "${random_name}"
mktemp
, it is designed to solve such problems.