I'm adapting this script to insert one file's content into another file. This is what I have now:
# Check if first and second parameters exist
if [ ! -z "$2" ]; then
# Check if the supplied file exist
if [ -e $2 ]; then
sed -i -e "2i$STRING" $2
echo "The string "$STRING" has been successfully inserted."
echo "The file does not exist."
echo "Error: both parameters must be given."
I run it with:
./prepend.sh content.txt example.txt
The script's output:
sed: -e expression #1, char 24: unterminated `s' command
The string "first_line
second_line" has been successfully inserted.
And the content of
example.txt file remains the same, when I want it to be like this: