I have a file and a symlink:
file: ~/${USER_HOME}/blabla/.cheatsheet
symlink: ~/.cheatsheet (is linked to file above)
Now in my script I do some operations with the file, e.g. add a line and sort the file alphabetically and move it:
addOneCommand() {
file"=~/.cheatsheet"
# add it to the file
echo "${cmd}" >> "${file}"
# sort file instantly
cat "${file}" | sort > "${file}".tmp
mv "${file}".tmp "${file}"
}
But the real file behind the symlink doesn't get affected by the script (e.g. not sorted alphabetically). What can I do to work with "symlinked files" in bash scripts?
Thanks.
file"=~/.cheatsheet"
is not going to work.