Page 1 of 1
Need to get all flat files into one flat file
Posted: Tue May 19, 2009 12:38 pm
by reshma11
I have a requirement that I need to get all the output flat files into one flat file separated with file name. Can any one help me on this how to get this done.
Posted: Tue May 19, 2009 12:42 pm
by chulett
So... you need to generate it like that from the start or can you generate them separately and then combine them afterwards? The latter is just 'concatenation' in a loop and something you could script. The former... would have to ponder that.
![Confused :?](./images/smilies/icon_confused.gif)
Posted: Tue May 19, 2009 12:45 pm
by reshma11
I am generating them separately and I need to combine them afterwards. How can I do that.
Posted: Tue May 19, 2009 12:55 pm
by nagarjuna
i think you can do it in sequential file stage . Read multiple files using a sequential file and use the option FileName column.
Posted: Tue May 19, 2009 1:09 pm
by chulett
As noted, a script would be fairly simple. Do a 'for' loop thru the files, echo the filename to the output file and then cat the file itself. Use '>>' redirection in each case to append rather than overwrite.
can do it in sequential file stage
Posted: Wed May 20, 2009 9:43 am
by reshma11
In sequential file stage options filter = awk ' BEGIN { print "#pHEADER#"; } { print; } END { print "#pTRAILER#"; } '
Thanks
Posted: Wed May 20, 2009 10:15 am
by Sainath.Srinivasan
Code: Select all
for fileName in `ls -1`
do
echo $fileName >> yourFileName
cat $fileName >> yourFileName
done