Hi,
So far i've made a script that takes two argument, 1st is the contents and the 2nd is the named file. At the moment i've managed to insert new contents as a new line at the top, but i want to ask how can you insert contents in the middle of the file?
Source Code
#!/bin/bash
#Write content to exisiting file
if [ $# -ne 2 ]
then
echo "run the script again and insert two values please"
exit 0
fi
{
printf "%s\n" "$1"
cat "$2"
} > tempfile.$$
mv tempfile.$$ "$2"
Many thanks