How do I write to a file using sed and/ or awk.
My problem. I have a file that needs to be updated after and install. I want to script into the installation script to get the input from the user and plop that into the config file.
I can get the line number that I want to change by doing a sed command (sed -n -e /foo/= conf.file > linenum.file) and then reading the line num into a variable. I just don't know how to write the data that I need to write on that line number.
This is my test script so far:
echo "enter some text to write to file here:"
read enteredtext
sed -n -e /foo/= conf.file > linenum.file
read lineNum <linenum.file
# Now I have no clue as to what to do...
# I know that I have to stick foo at the beginning of the
# line that I am inserting (foo <entered text>)
any help? Idea? Am I doing things completely wrong... I know there has to be a better way to accomplish what I am doing
Thanks
-cmf
My problem. I have a file that needs to be updated after and install. I want to script into the installation script to get the input from the user and plop that into the config file.
I can get the line number that I want to change by doing a sed command (sed -n -e /foo/= conf.file > linenum.file) and then reading the line num into a variable. I just don't know how to write the data that I need to write on that line number.
This is my test script so far:
echo "enter some text to write to file here:"
read enteredtext
sed -n -e /foo/= conf.file > linenum.file
read lineNum <linenum.file
# Now I have no clue as to what to do...
# I know that I have to stick foo at the beginning of the
# line that I am inserting (foo <entered text>)
any help? Idea? Am I doing things completely wrong... I know there has to be a better way to accomplish what I am doing
Thanks
-cmf