thanks for all the replies. why not use perl? simply because i don't know perl yet and i want it in bash script. but i dont know how to read lines and process it. ang gamit ko lang ng read e pag may user input. di ko lam na pwede pala tong mga script na to.
kuya mhac, di po c yung code. parang algorithm lang yun kung pano gagawin. zak, mas nagustuhan ko nga ang zsh, konti plng nakita ko functionality nya na mas ok kaysa bash kaya lang simula plang kasi e bash na gamit ko, kaya di ko pa mapalitan ng zsh. i have to study it first. sa uulitin.. God bless you all.. On 6/26/06, Martin Acupanda <[EMAIL PROTECTED]> wrote:
assuming <model> is column 1; <serial> is column is column 5 and delimiter is comma (,). We'll call this script as myscript. Then try experimenting.... #!/bin/bash echo "<?xml ?>" echo "<hello>" cat path/to/file | while read THELINE do MYMODEL=$(echo $THELINE | cut -d, -f1) MYSERIAL=$(echo $THELINE | cut -d, -f5) echo "\<data model\=\"\<$MYMODEL\>\" serial\=\"\<$MYSERIAL\>\"\>" done echo "</hello>" Make this executable. chmod +x myscript Now run the script. ./myscript > myxmlfile On 6/24/06, jhuniepi <[EMAIL PROTECTED]> wrote: > hello to all, i have a list of text files in /home/cj/test/ the files are in the format <model>,,,<serial> of 1000 lines each. these are text files. i wil read these one by one, line by line, and process each line. so that i can out put to xml file in the format below: <?xml ?> <hello> <data model="<model>" serial="<serial>"> <data model="<model>" serial="<serial>"> <data model="<model>" serial="<serial>"> <data model="<model>" serial="<serial>"> </hello> how to do this in bash. please dont use perl. TIA -- cj pangilinan linux user, java programmer _________________________________________________ Philippine Linux Users' Group (PLUG) Mailing List [email protected] (#PLUG @ irc.free.net.ph) Read the Guidelines: http://linux.org.ph/lists Searchable Archives: http://archives.free.net.ph -- Regards, Martin Acupanda _________________________________________________ Philippine Linux Users' Group (PLUG) Mailing List [email protected] (#PLUG @ irc.free.net.ph) Read the Guidelines: http://linux.org.ph/lists Searchable Archives: http://archives.free.net.ph
-- cj pangilinan linux user, java programmer _________________________________________________ Philippine Linux Users' Group (PLUG) Mailing List [email protected] (#PLUG @ irc.free.net.ph) Read the Guidelines: http://linux.org.ph/lists Searchable Archives: http://archives.free.net.ph

