I have a few files which needed to be backed up from multiple directories. Few of the files are from the home
directory. For example, I need to back up the ~/.ssh/config
file. There are multiple files that have to be backed up. The array of files looked like something below.
array=("~/.bash_aliases" "~/.bashrc" "~/.ssh/config" "~/.ssh/set_git_profile.sh")
I looped the array using the for...do...done
loop. However, each item in the array was a string and I was unable to resolve ~
with the actual path. For example, ~
to be replaced with /home/<user>
in all the file names.
The Final array should look like something below for the user called rahul
array=("/home/rahul/.bash_aliases" "/home/rahul/.bashrc" "/home/rahul/.ssh/config" "/home/rahul/.ssh/set_git_profile.sh")