Append strings to file

Hi,
How do i modify "write characters to file.vi" such that every time i append a new string to the same file, it will start at a new line?
There is this parameter in the vi that is called "convert eol"? Read the help file but could not figure out what is a end of line marker. Please help.
Thanks.

Hi,
the easiest way is to concatenate EOL symbol with your string and then write this new string to the file.
So you will write something like
EOL"your string". (or "/nyour string" in codes)
EOL symbol and "Concatenate strings.vi" you can find in "Functions/String/..."
Good luck.
Oleg Chutko.

Similar Messages

  • How to read appended objects from file with ObjectInputStream?

    Hi to everyone. I'm new to Java so my question may look really stupid to most of you but I couldn't fined a solution by myself... I wanted to make an application, something like address book that is storing information about different people. So I decided to make a class that will hold the information for each person (for example: nickname, name, e-mail, web address and so on), then using the ObjectOutputStream the information will be save to a file. If I want to add a new record for a new person I'll simply append it to the already existing file. So far so good but soon I discovered that I can not read the appended objects using ObjectInputStream.
    What I mean is that if I create new file and then in one session save several objects to it using ObjectOutputStream they all will be read with no problem by ObjectInputStream. But after that if in a new session I append new objects they won't be read. The ObjectInputStream will read the objects from the first session after that IOException will be generated and the reading will stop just before the appended objects from the second session.
    The following is just a simple test it's not actual code from the program I was talking about. Instead of objects containing different kind of information I'm using only strings here. To use the program use as arguments in the console "w" to create new file followed by the file name and the strings you want save to the file (as objects). Example: "+w TestFile.obj Thats Just A Test+". Then to read it use "r" (for reading), followed by the file name. Example "+r TestFile.obj+". As a result you'll see that all the strings that are saved in the file can be successfully read back. Then do the same: "+w TestFile.obj Thats Second Test+" and then read again "+r TestFile.obj+". What will happen is that the strings only from the first sessions will be read and the ones from the second session will not.
    I am sorry for making this that long but I couldn't explain it more simple. If someone can give me a solution I'll be happy to hear it! ^.^ I'll also be glad if someone propose different approach of the problem! Here is the code:
    import java.io.*;
    class Fio
         public static void main(String[] args)
              try
                   if (args[0].equals("w"))
                        FileOutputStream fos = new FileOutputStream(args[1], true);
                        ObjectOutputStream oos = new ObjectOutputStream(fos);
                        for (int i = 2; i < args.length ; i++)
                             oos.writeObject(args);
                        fos.close();
                   else if (args[0].equals("r"))
                        FileInputStream fis = new FileInputStream(args[1]);
                        ObjectInputStream ois = new ObjectInputStream(fis);
                        for (int i = 0; i < fis.available(); i++)
                             System.out.println((String)ois.readObject());
                        fis.close();
                   else
                        System.out.println("Wrong args!");
              catch (IndexOutOfBoundsException exc)
                   System.out.println("You must use \"w\" or \"r\" followed by the file name as args!");
              catch (IOException exc)
                   System.out.println("I/O exception appeard!");
              catch (ClassNotFoundException exc)
                   System.out.println("Can not find the needed class");

    How to read appended objects from file with ObjectInputStream? The short answer is you can't.
    The long answer is you can if you put some work into it. The general outline would be to create a file with a format that will allow the storage of multiple streams within it. If you use a RandomAccessFile, you can create a header containing the length. If you use streams, you'll have to use a block protocol. The reason for this is that I don't think ObjectInputStream is guaranteed to read the same number of bytes ObjectOutputStream writes to it (e.g., it could skip ending padding or such).
    Next, you'll need to create an object that can return more InputStream objects, one per stream written to the file.
    Not trivial, but that's how you'd do it.

  • Append to text file

    i'm trying to append some string to a file but it gives me error while compiling.
    here's my code:
    import java.io.FileOutputStream;
    import java.io.File;
    import java.io.IOException;
    import java.util.Calendar;
    import java.util.Date;
    import java.awt.*;
    import java.text.SimpleDateFormat;
    public class testWrite
         public static void main(String args[])
              File outputFile=new File("file.txt");
              try
                   Calendar myCalendar = Calendar.getInstance();
         FileWriter oStream=new FileWriter(outputFile,true);
                   FileOutputStream oStream=new FileOutputStream(outputFile,true);
                   SimpleDateFormat datfmt = new SimpleDateFormat( "dd.MM.yyyy HH:mm:ss" );
                   Date date=new Date();
                   String strDate=datfmt.format(date);
                   oStream.write(strDate.getBytes());
                   oStream.close();
              catch(IOException e)
    can someone tell me what's wrong with it.

    here is the corrected programme
    import java.io.*;
    import java.io.FileOutputStream;
    import java.io.File;
    import java.io.IOException;
    import java.util.Calendar;
    import java.util.Date;
    import java.awt.*;
    import java.text.SimpleDateFormat;
    public class testWrite
    public static void main(String args[])
              //File outputFile=new File("file.txt");
              try
              Calendar myCalendar = Calendar.getInstance();
              //FileWriter oFileWriter=new FileWriter("file.txt",true);
              FileOutputStream oStream=new FileOutputStream("file.txt",true);
              SimpleDateFormat datfmt = new SimpleDateFormat( "dd.MM.yyyy HH:mm:ss" );
              Date date=new Date();
              String strDate=datfmt.format(date);
              oStream.write(strDate.getBytes());
              oStream.close();
              catch(IOException e)
    U had used file object in the constructor of the fileOutputStream object which is not the argument the constructor expects,the constructor expects a String with the fileName in it.

  • Append to Zip file

    Hi everyone,
    I have created a zip file (test.zip), but i cant figure out how to append a text file to it.
    Can anybody help?

    http://java.sun.com/j2se/1.5.0/docs/api/java/util/zip/ZipInputStream.html#createZipEntry(java.lang.String)

  • How to append two CSV files using ftp

    Hi
    Please let me know the FTP command to append the two .CSV files into one .CSV file.
    e.g.
    Let me explain:
    one CSV file has the fields F1 , F2, F3 , F4 and has 5 records
    another CSV file has the same sequence of fields F1, F2, F3, F4 and has 10 records
    after appending both the files , I must get 15 records.
    Thanks
    Alok

    Ok I will try out.
    I am illustrating my requirement as follow
    File#1 (type .CSV)
    F1     F2     F3     F4
    100   566    89     86   
    235   256    56     12
    File#2 (type .CSV)
    F1     F2     F3     F4
    56     56     98     102
    12     23     36      523
    23      56     56    89
    Now we want to Append File#1 to File#2 as follow: 
    F1    F2    F3     F4
    100   566    89     86   
    235   256    56     12   
    56     56     98     102
    12     23     36      523
    23      56     56    89
    Please suggest now that which command would be appropiate.
    Alok

  • Problem with Append mode in File Receiver

    Hello,
    I am facing some problem with Append Mode in File Receiver.
    In channel config, i have given :
    Construction Mode : Append
    File Type : Text
    Message Protocol : File Content Conversion
    The size of the file which i am trying to send is about 9.5MB.
    I got this error,
    "Recovering from loss of connection to database; message
    loaded into queue by recover job: System Job (Failover Recovery)".
    So, it would seem that there was a loss of connnection to the database    
    while the file was being written.
    Note -  XI successfully recovered from the connection loss and   
    successfully wrote the file, however since the communication channel  
    was set to append, it appended to the partial file that was written   
    before the database connection loss. This is not correct. The file    
    should have been overwritten after the recovery even though the communication
    channel was configured to append.                                     
    Can anyone help me on this regard.
    Thanks,
    Soorya.

    Hi Venkat,
    I would suggest u to split the file in to chunks if u face any problem in processing at a time in append mode and also
    Memory Requirements are must 4 processing huge files:
    Q: Which memory requirements does the File Adapter have? Is there a restriction on the maximum file size it can process?
    A: The maximum file size that can be processed by the File Adapter depends on a number of factors:
    o The most important one is the size of the Java heap, which is shared among all messages processed at a certain point in time. In order to be able to process larger messages without an out of memory error (OOM), it is recommended to increase the size of the available Java heap and/or to reduce the concurrency in the system so that fewer messages are processed in parallel.
    o Another factor negatively influencing the maximum message size in releases up to and including XI 3.0 SP 13 is an enabled charcter set (encoding) conversion if the message type is set to "Text".
    o Using the transport protocol "File Transfer Protocol (FTP)" also uses more memory for processing than the transport protocol "File System (NFS)" (up to and including XI 3.0 SP 13).
    o If the Message Protocol "File Content Conversion" is used in a File Sender channel, consider that not only the size of the input file affects the File Adapter's memory usage, but even more the size of the XML resulting from the conversion, which is usually a few factors larger than the original plain text file.
    To reduce the memory consumption in this scenario, consider configuring the setting "Maximum Recordsets per Message" for the sender channel. This will cause the input file to be split into multiple smaller mesages.
    Plz do refer the following links:
    U may plan the availability of ur communication channel using "Planning Availability Times" feature
    http://help.sap.com/saphelp_nw04/helpdata/en/45/06bd029da31122e10000000a11466f/frameset.htm
    /people/sravya.talanki2/blog/2005/11/29/night-mare-processing-huge-files-in-sap-xi
    hi check the below links for reference
    https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/10748ef7-b2f0-2910-7cb8-c81e7f284af5
    https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/7086f109-aaa7-2a10-0cb5-f69bd2affd2b
    https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/2498bf90-0201-0010-4884-83568752a857
    https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/cc1ec146-0a01-0010-90a9-b1df1d2f346f
    Regards,
    Vinod.

  • Get specific Strings from File

    Good morning to every one.
    I 've got a text file which contains a customer number and an order number, coded as we see in the picture below:
    I am trying to develop a tool in Visual Studio, which it reads the file line-by-line and fills a listbox, with the order_number and the customer number. From the file above, I know that the order number are the digits on the first 'column' after the leading-zeros,
    until '/', and the customer number are the digits without zeros in the 'third' column before 'CUSTOMER_NUMBER'. My form looks like:
    The problem is, that the number of before the fields in file, are not equal in every line.
    So, my question is how I can retrieve the 'order number' and 'customer number' from the text file and copy the results to list box, after clicking on 'Get Strings' button, like:
    359962656   2238914
    359562804   2238914
    etc...
    I attach my code here:
    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Linq;
    using System.Text;
    using System.Windows.Forms;
    using System.IO;
    namespace ReadStringFileApp
    public partial class frmMain : Form
    public frmMain()
    InitializeComponent();
    OpenFileDialog openfile = new OpenFileDialog();
    //openfiledialog to pickup filename
    private void btnFindFile_Click(object sender, EventArgs e)
    openfile.Filter = "Text|*.txt";
    if (openfile.ShowDialog() == DialogResult.OK)
    lbxResults.Items.Clear();
    txtFilepath.Text = openfile.FileName.ToString();
    //get strings from file
    private void btnGetStrings_Click(object sender, EventArgs e)
    //check if there is a file path on textbox
    if (txtFilepath.Text == "")
    MessageBox.Show("No File Select. Please select a file", "Error File Name", MessageBoxButtons.OK, MessageBoxIcon.Error);
    btnFindFile.Focus();
    return;
    //create list for all lines inside file
    List<string> lines = new List<string>();
    string line;
    using (StreamReader r = new StreamReader(@txtFilepath.Text))
    while ((line = r.ReadLine()) != null)
    string ordernum;//string for order number
    string customer;//string for customer number
    //line = ordernum + "\t" + customer; //concatenate results to fill the list box
    lbxResults.Items.Add(line);
    r.Close(); //close file
    private void btnExportToFIle_Click(object sender, EventArgs e)
    //check if listbox is empty
    if (lbxResults.Items.Count == 0)
    MessageBox.Show("Result List is empty! Choose a file to proceed.", "Error Result List", MessageBoxButtons.OK, MessageBoxIcon.Error);
    btnGetStrings.Focus();
    return;
    //read listbox contents and parse to a list object
    List<string> list = new List<string>();
    foreach (String i in lbxResults.Items)
    list.Add(i);
    //Create a file in c: with results
    File.WriteAllLines(@"C:\export-test.txt", list, Encoding.Default);
    MessageBox.Show("File export completed!", "File Export", MessageBoxButtons.OK, MessageBoxIcon.Information);
    Thank you in advanced

    @ Joel Engineer
    and@
    Val10
    I combined your responses and I get my results correctly. I attached the code I rewrite for further use:
    private void btnGetStrings_Click(object sender, EventArgs e)
    //check if there is a file path on textbox
    if (txtFilepath.Text == "")
    MessageBox.Show("No File Select. Please select a file", "Error File Name", MessageBoxButtons.OK, MessageBoxIcon.Error);
    btnFindFile.Focus();
    return;
    //create list for all lines inside file
    List<string> lines = new List<string>();
    string line;
    using (StreamReader r = new StreamReader(@txtFilepath.Text))
    while ((line = r.ReadLine()) != null)
    string order_customer;
    Regex reg = new Regex("0*");
    //set an string array, to split the file in columns positions, defining the characters
    string[] daneio = line.Split(new char[] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries);
    //get order number from the first column
    var ordernum_zeros = reg.Match(daneio[0]).Value;
    daneio[0] = daneio[0].Replace(ordernum_zeros, String.Empty);
    daneio[0] = daneio[0].Substring(0, daneio[0].IndexOf("/"));
    //get customer column, without zeros
    var customer_zeros = reg.Match(daneio[5]).Value;
    daneio[2] = daneio[2].Replace(customer_zeros, String.Empty);
    daneio[2] = daneio[2].Substring(0, daneio[5].IndexOf("CUSTOMER_NUMBER"));
    //combine the result in listbox
    order_customer = daneio[0] + "\t" + daneio[2];
    lbxResults.Items.Add(order_customer);
    r.Close(); //close file
    Thank you for your help!

  • External Table which can handle appending multiple csv files dynamic

    I need an external table which can handle appending multiple csv files' values.
    But the problem I am having is : the number of csv files are not fixed.
    I can have between 2 to 6-7 files with the suffix as current_date. Lets say it will be like my_file1_aug_08_1.csv, my_file1_aug_08_2.csv, my_file1_aug_08_3.csv etc. and so on.
    I can do it by following as hardcoding if I know the number of files, but unfortunately the number is not fixed and need to something dynamically to inject with a wildcard search of file pattern.
    CREATE TABLE my_et_tbl
      my_field1 varchar2(4000),
      my_field2 varchar2(4000)
    ORGANIZATION EXTERNAL
      (  TYPE ORACLE_LOADER
         DEFAULT DIRECTORY my_et_dir
         ACCESS PARAMETERS
           ( RECORDS DELIMITED BY NEWLINE
            FIELDS TERMINATED BY ','
            MISSING FIELD VALUES ARE NULL  )
         LOCATION (UTL_DIR:'my_file2_5_aug_08.csv','my_file2_5_aug_08.csv')
    REJECT LIMIT UNLIMITED
    NOPARALLEL
    NOMONITORING;Please advice me with your ideas. thanks.
    Joshua..

    Well, you could do it dynamically by constructing location value:
    SQL> CREATE TABLE emp_load
      2      (
      3       employee_number      CHAR(5),
      4       employee_dob         CHAR(20),
      5       employee_last_name   CHAR(20),
      6       employee_first_name  CHAR(15),
      7       employee_middle_name CHAR(15),
      8       employee_hire_date   DATE
      9      )
    10    ORGANIZATION EXTERNAL
    11      (
    12       TYPE ORACLE_LOADER
    13       DEFAULT DIRECTORY tmp
    14       ACCESS PARAMETERS
    15         (
    16          RECORDS DELIMITED BY NEWLINE
    17          FIELDS (
    18                  employee_number      CHAR(2),
    19                  employee_dob         CHAR(20),
    20                  employee_last_name   CHAR(18),
    21                  employee_first_name  CHAR(11),
    22                  employee_middle_name CHAR(11),
    23                  employee_hire_date   CHAR(10) date_format DATE mask "mm/dd/yyyy"
    24                 )
    25         )
    26       LOCATION ('info*.dat')
    27      )
    28  /
    Table created.
    SQL> select * from emp_load;
    select * from emp_load
    ERROR at line 1:
    ORA-29913: error in executing ODCIEXTTABLEOPEN callout
    SQL> set serveroutput on
    SQL> declare
      2      v_exists      boolean;
      3      v_file_length number;
      4      v_blocksize   number;
      5      v_stmt        varchar2(1000) := 'alter table emp_load location(';
      6      i             number := 1;
      7  begin
      8      loop
      9        utl_file.fgetattr(
    10                          'TMP',
    11                          'info' || i || '.dat',
    12                          v_exists,
    13                          v_file_length,
    14                          v_blocksize
    15                         );
    16        exit when not v_exists;
    17        v_stmt := v_stmt || '''info' || i || '.dat'',';
    18        i := i + 1;
    19      end loop;
    20      v_stmt := rtrim(v_stmt,',') || ')';
    21      dbms_output.put_line(v_stmt);
    22      execute immediate v_stmt;
    23  end;
    24  /
    alter table emp_load location('info1.dat','info2.dat')
    PL/SQL procedure successfully completed.
    SQL> select * from emp_load;
    EMPLO EMPLOYEE_DOB         EMPLOYEE_LAST_NAME   EMPLOYEE_FIRST_ EMPLOYEE_MIDDLE
    EMPLOYEE_
    56    november, 15, 1980   baker                mary            alice     0
    01-SEP-04
    87    december, 20, 1970   roper                lisa            marie     0
    01-JAN-99
    SQL> SY.
    P.S. Keep in mind that changing location will affect all sessions referencing external table.

  • Appending multiple *.csv files while retaining the original file name in the first column

    Hi guys it's been awhile.
    I'm trying to append multiple *.csv files while retaining the original file name in the first column, the actual data set is about 40 files.
    file a.csv contains:
    1, line one in a.csv
    2, line two in a.csv
    file b.csv contains:
    1, line one in b.csv
    2, line two in b.csv
    output.csv result is this:
    I would like this:
    a.csv, 1, line one in a.csv
    a.csv, 2, line two in a.csv
    b.csv, 1, line one in b.csv
    b.csv, 2, line two in b.csv
    Any suggestions to speed up my hobbling attempts would be aprieciated
    Thanks,
    -SS
    Solved!
    Go to Solution.

    What you could do is given in the attachment.
    Started with 2 files :
    a.csv
    copy of a.csv
    Both with data :
    1;1.123
    2;2.234
    3;3.345
    Output :
    a.csv;1;1.123
    a.csv;2;2.234
    a.csv;3;3.345
    Copy of a.csv;1;1.123
    Copy of a.csv;2;2.234
    Copy of a.csv;3;3.345
    If you have more questions, just shoot
    Kind regards,
    - Bjorn -
    Have fun using LabVIEW... and if you like my answer, please pay me back in Kudo's
    LabVIEW 5.1 - LabVIEW 2012
    Attachments:
    AppendingCSV.JPG ‏73 KB

  • Appending a .sql file to a pdf

    Is it possible to append a .sql file to a PDF as an Appendix. I am using Acrobat Pro 9.

    Hi randha m,
    What actually you mean by append. Do you mean attach. Try to elaborate little more your query.
    Regards,
    Ajlan Huda.

  • Search a string in file

    I want to search for a string in file. I can do it reading the file in line by line and search each line but that would be more expensive. Is there are any api/freeware library, which can help me to search for a string in file?
    - R

    You can eliminate the overhead of creting strings, and also of translating bytes to chars, but that's all you can do. Do not forget:
    Premature optimization is the root of all evil.
    Using ByteBuffer and java.nio could be the best. I do not believe there's a library doing exactly what you need - I suppose nobody really needs it and it's easy to do.

  • Appending to text file

    Hello everyone
    I am working on a galil motor controller for a stepper motor. I have a fully functioning code for the stepper motor but I am now trying to create a data file to log the motors activity. I have created two attempts at appending to a file everytime the motor changes position. One of my attempts was a shift register using a while loop, it works the only problem with it is that it is constantly running. This makes the motor run constantly so if I set an angle itll try to keep setting it as long as the while loop is running.
    Attached is my VI I have worked very hard at this. Please let me know how i could fix it
    Thanks
    Attachments:
    galil mc USER rotationTESTING 5-13.vi ‏251 KB
    galil mc USER rotation 5-12-14.vi ‏237 KB

    You write to the file before setting the pointer to the end.  Here, I made a very simple edit that should get you going.
    There are only two ways to tell somebody thanks: Kudos and Marked Solutions
    Unofficial Forum Rules and Guidelines
    Attachments:
    Append to File.PNG ‏50 KB

  • Append string to stringbuffer in same line

    I have stringbuffer in which i append string thiesestring is of variable lengt
    has different value .I want that when i append string to stringbuffer it append
    to same line .I use append method of stringbuffer.But the whole value is not
    in same line it breaks into many line all lines are not of same size.
    Thanks

    Try making the textarea larger and see if it still
    shows on a new line...Textarea width is very large .There are many line break sometimes all lines
    are of different length so there is no issue of word wrap .I check the output
    sometimes it gives newline when it encounter space but not always .there are also spaces in single line .Sometimes it gives new line when it encounter >
    and sometimes it continue in same line after enconter > .
    Thanks

  • Append an existing file?

    Hello world,
    I'm stuck in a predicament: The storage guys have asked me to reduce the frequency of backups on three of our instances to save bandwidth on the WAN when the backup files are copied across to another datacenter. The application owners do not want to backup
    any less frequently. 
    We do daily full backups and Tr-log backups every 15 minutes throughout the day.
    Storage have advised that the SAN only copies changes (ie new files or the changes to existing ones)
    Is it possible/ would it be of any benefit, to backup and append an existing file? Can I do this with the logs as with the databases?
    Thanks in advance

    Storage have advised that the SAN only copies changes (ie new files or the changes to existing ones)
    I am not very sure that it will pick changes from existing ones, I think if it sees the file is changed it will start coping as 1 big file and will not solve your purpose. You might get it reconfirm with storage on this. Also even if it does like you said
    I wonder if next backup runs and file is still getting copied over then backup will start failing saying "file is in use".
    If application owner is saying 15 min log backup then we cant reduce the frequency, but if you have some other drive/disk where you can divert tlog backup say for 2 hours then you can run differential backup every 2 hour which goes to SAN. You will be safe
    even if something happen you have tlog on 1 drive and
    differential get copied to other datacenter. (But point in time recovery will be issue as you will not have any tlog backups for restore)
    I cant think of anything else to reduce frequency, but for bandwidth see if you can use compress(enterprise edition) or zip backup file to save bandwidth.

  • [SOLVED] sed; string with file

    Hi,
    Is it possible the to replace a string with file contents, for example; i have the following XML file:
    <?xml version="1.0" encoding="UTF-8"?>
    <modification>
    <id>Testing</id>
    <version>0.0.1</version>
    <vqmver required="true">2.5.0</vqmver>
    <author><![CDATA[Dragon707]]></author>
    <file name="template/a.tpl">
    <operation error="log">
    <search position="before"><![CDATA[
    whooo
    ]]></search>
    <add><![CDATA[
    @include[src/script_whooo.js]
    ]]></add>
    </operation>
    </file>
    <file name="template/b.tpl">
    <operation error="log">
    <search position="before"><![CDATA[
    wheee
    ]]></search>
    <add><![CDATA[
    @include[src/script_wheee.js]
    ]]></add>
    </operation>
    </file>
    </modification>
    And the file src/script_whooo.js contains:
    alert(1);
    And the file src/script_wheee.js contains:
    alert(2);
    What i want is that the string "@include[src/script_whooo.js]" replaces the content with src/script_whooo.js. The expected output is then:
    <?xml version="1.0" encoding="UTF-8"?>
    <modification>
    <id>Testing</id>
    <version>0.0.1</version>
    <vqmver required="true">2.5.0</vqmver>
    <author><![CDATA[Dragon707]]></author>
    <file name="template/a.tpl">
    <operation error="log">
    <search position="before"><![CDATA[
    whooo
    ]]></search>
    <add><![CDATA[
    alert(1);
    ]]></add>
    </operation>
    </file>
    <file name="template/b.tpl">
    <operation error="log">
    <search position="before"><![CDATA[
    wheee
    ]]></search>
    <add><![CDATA[
    alert(2);
    ]]></add>
    </operation>
    </file>
    </modification>
    Last edited by Dragon707 (2014-11-14 12:06:22)

    Procyon wrote:
    I don't think you can get the filename from the file into the 'r' command of sed without naming the filenames explicitly.
    Try this in bash:
    while read; do
    [[ "$REPLY" =~ ^(.*)@include\[([^\]]*)\](.*)$ ]] &&
    REPLY=${BASH_REMATCH[1]}$(cat "${BASH_REMATCH[2]}")${BASH_REMATCH[3]}
    echo "$REPLY"
    done < script.xml
    It only does one @include[] per line though.
    Thanks for your answer, i got it to work however, i still miss the tabs in the output.xml file. Is there a way to keep the tabs in the output.xml?
    #!/bin/bash
    INPUT="input.xml"
    OUTPUT="output.xml"
    echo "" > $OUTPUT
    while read; do
    [[ "$REPLY" =~ ^(.*)@include\[([^\]]*)\](.*)$ ]] &&
    REPLY=${BASH_REMATCH[1]}$(cat "${BASH_REMATCH[2]}")${BASH_REMATCH[3]}
    echo $REPLY >> $OUTPUT
    done < $INPUT

Maybe you are looking for