$ gcc -o c2xml -O2 convert_to_xml.c
$ ./c2xml <file> <output_xml>
And according to Zak, bash is not a good choice to process large text files. But it can get the work done.
On 6/25/06, Zak B. Elep <[EMAIL PROTECTED]> wrote:
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:
>
[...]
>
> how to do this in bash. please dont use perl.
Erm, why not? =)
Anyhow, here's one way to do it:
# prepare the XML header here, in `set.xml'
ls /home/cj/test | sed -e's/^\(.*\),,,\(.*\)$/<data model="\1"
serial="\2"> >> set.xml
# end the XML stream here
Then again, bash is not a good choice for processing large amounts of
text files, since you'd most likely use other tools (like sed above)
causing a fork of the current shell. Perl would be helpful here; you
could probably look at the standard Text modules for starters.
If you're still adamant into using shell, then I suggest you look into
Zsh.[0] Some folk even turned it into a rather useful IRC client.[1]
[0] http://www.zsh.org
[1] http://www.zsh.org/mla/users/2006/msg00582.html
Cheers,
Zakame
--
Zak B. Elep || http://zakame.spunge.org
[EMAIL PROTECTED] || [EMAIL PROTECTED]
1486 7957 454D E529 E4F1 F75E 5787 B1FD FA53 851D
_________________________________________________
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
--
Mhac Janapin
PBTS SysAd
=============
http://mulingsilang.blogspot.com
=============
I'm an Open Source Enthusiast. c",)
Mozilla Firefox 1 - getfirefox.com
Mozilla Thunderbird 1 - mozilla.org
OpenOffice.org
=============
_________________________________________________ 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

