I'm trying to make a simple bash script that takes an input file and replaces placeholders like &date
by the actual value (the date in this case)
Example:
text=$(sed -e "s/&file/$FILE/" -e "s/&date/$DATE/" $FILE)
echo $text
Problems:
- The newlines are removed, all the lines are jumbled together.
- Things like
/******
placed in the start of the file are changed to/bin /boot etc
(so the paths are resolved).*****/
will also be replaced.
Example:
Input:
/**********************************
hello
**********************************/
Output (line broken in the middle to make it readable):
/bin /boot /dev /etc /home /lib /lib64 /mnt
/opt /proc /root /run /sbin /srv /sys /tmp /usr /var hello parent/ parent_neighbor/
I guess I need to escape the file, but I could not find anywhere how to do it.