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
Tell me more
×
Super User is a question and answer site for
computer enthusiasts and power users. It's 100% free, no registration required.
|
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":
|
|||
|
|