I need to read data from a source and have to form a XML file using shell script. But first of all i don't know how to write multiple lines in a file using shell script
Use output redirection
Or use a "here document"
Better yet is to use a scripting/programming language that has support for XML. I like Perl and XML::LibXML but you may prefer something else.
The following creates a file named "file.txt" (or replaces the contents of the file if it already exists), and writes "foo" (without quotes) into it :
What you seem to look for is the following, appending the string "foo" (again, without quotes) in the file (and again, creating the file if it doesn't exist)
So the following code will write three lines to "file.txt":