Script or command line to comment out multiple lines in flat files

I am looking for a way to go through multiple flat files within the same directory for the occurance of a server name and if found to insert a comment (#) at the beginning of the line. Currently, I am grepping for the server name within the directory and then doing a vi on each individual flat file to comment out the line. The server name is separated by the pipe (|) symbol and each line of every file is in this format:
webservers:WEBSERVER|Env Name|servername|application name
So, in the above, I am grepping for the servername part and if found in there, I want to change the line to:
#webservers:WEBSERVER|Env Name|servername|application name
I would think there would be a way of doing this either with command line Perl or with maybe awk or sed. Any suggestions would be greatly appreciated.

You could do something like this with a ksh shell script:
#!/usr/bin/ksh
for file in `ls`; do
        echo $file
        sed 's/^webserver/#webserver/g' $file > $file.parsed; mv $file.parsed $file
doneThis will go through everyfile in the directory and search for "start of line" webserver and replace it with "#webserver". Then the file will get move back to the original file name.
If you just want to change certain files ie. only filenames with the word "server" in it, then change:
for file in `ls`; do to something like
for file in `ls *server*`; doHope this help...
Cheers
pdaemon

Similar Messages

  • Create ecatt script for one sales order creation with multiple line items

    Hi ,
    I want to create a ecatt script for one sales order creation with multiple line items. Preferably SAP GUI.
    This selection of data will be from an external file/ variants which will have only one row of data in it.
    Firstly: I have to sort the external file having same PO Numbers in an order.Group them together.
    Second: I have to create sales order for those many line items having same PO Number.
    Best Regard
    Taranum

    Hi Micky
    Firstl you should upload the Line items for a particular sales Order in an Internal table
    and then pass that internal table to your BAPI during your coding corresponding to a particu;lar sales order
    In case of any issues pls revert back
    Reward points if helpful
    Regards
    Hitesh

  • [svn:bz-trunk] 21017: Comment out the line in Tomcat7Valve that was causing the build to fail.

    Revision: 21017
    Revision: 21017
    Author:   [email protected]
    Date:     2011-04-05 05:59:33 -0700 (Tue, 05 Apr 2011)
    Log Message:
    Comment out the line in Tomcat7Valve that was causing the build to fail. I am not sure what this line was supposed to do - likely, this is not-functional right now.
    Modified Paths:
        blazeds/trunk/modules/opt/src/tomcat/flex/messaging/security/Tomcat7Valve.java

    soon as you start up the computer, keep hitting the F1 key.  That should get you into the BIOS.
    Also, try disabling Active System Protection for your freezing issues.  I'm using XP so  I don't know where to tell you to find it in Vista.

  • Multiple IDocs - XI - Flat file

    We are looking at a scenario to send multiple IDOCS from SAP to Flat File. We implemented this using the Collect Pattern in BPM, merge all the IDocs into a single message and write it in a file. But is there any a way to avoid BPM and still be able to send multiple IDOCS in a package to be written onto one file?
    Thanks
    Vinoda

    Hi,
    I think this is possible using PACKAGING.
    Check this note <b>814393</b> on Service Market Place.
    <i>You want to create or process an XI message with multiple instances of an IDoc (of the same IDoc or extension type) in the mapping.
    The payload of the relevant message is to have the following the format:
    <IDOCTYP>
    <IDOC>...</IDOC>
    <IDOC>...</IDOC>
    </IDOCTYP>
    To be able to process these messages in the message mapping of the source system and to create them in the target system, you need an XML schema for the IDOC that allows multiple instances of the IDOCtag.
    If the relevant IDOC is imported into the Integration Repository, the system generates an XML schema that sets the number of instances of the IDOC tag to exactly one.
    The following describes how you can manually change the XML schema so that multiple instances of the IDOC tag are allowed, and how you can make the modified XML schema available to an adequate message mapping.
    Other terms
    IDoc packaging
    Reason and Prerequisites
    The relevant IDoc is imported into the Integration Repository.
    Solution
    1) Log on to the Integration Repository.
    2) Open the relevant IDoc in the object editor.
    3) Select the "Export XSD" menu option in the "Tools" menu.
    4) In the subsequent dialog box, assign a file name and save the data to the hard disk of your local PC.
    5) Open the file that you have saved in step 4 in an adequate editor (for example, Notepad) for editing.
    6) Locate the first entry: <xsd:element name="IDOC" type="<
    Idocname>"> and add the following expression, maxOccurs="unbounded", between the value of the type attribute and the closing angular bracket.
    Example:
    <xsd:element name="IDOC" type="ADR2MAS.ADR2MAS02"
    maxOccurs="unbounded">
    7) Save the modified file to the hard disk of your local PC.
    8) In the message mapping, use the file saved in step 7 instead of the imported IDoc by using the "Import XML or XSD" function in the mapping tool to select the source or target messages.
    </i>
    Regards,
    Bhavesh

  • Error while trying to process multiple Recordsets in Flat file.

    Hi All,
    I am working on Flat File to Flat File scenario and my structure is as follows.
    Recordset
         Record1
              Field1
              Field2
         Record2
              Field3
              Field4
         |
         Record9
              Field5
              Field6
         I am going to receiver multiple Recordsets from my input and need to pass them as output flat file after doing some manipulations in mapping(I am using Java mapping).
         In Moni I am able to see multiple Recordset XMLs created but the message is failing in receiver communication channel with error
    "Failed to process message content. Reason: Exception in XML Parser (format problem?):'java.lang.Exception: Message processing failed in XML parser: 'Conversion configuration error: Unknown structure '' found in document', probably configuration error in file adapter (XML parser error)' (Software version: 3.0.1)"
         When I am trying to pass Single Recordset I am able to see the output, but when I am trying with multiple Recordsets it is throwing error.
         Can anybody help me in finding the root cause to this problem.
         My Receiver channel Content conversion is as follows.
         RecordsetStructure: Record1,Record2, -- - - ,Record9
              Record1.fieldFixedLengths     
              Record1.fieldNames
              Record1.endSeparator so on till Record9
    Regards,
    Jayaram.G

    You might want to check the following things
    Are u specifying field names,separators for Record1,Record2..Record9.
    Is you occurence repeats after record1..record9 again?
    Change your  structure occurence as per the runtime data you provide..
    See whether your java mapping modifies the structure that does not match with fcc configuration. You might want to pay attention over there too.

  • Blank lines inserted at the end of the flat file generated

    Hi,
    my scenario is idoc to flat file. for each item node in the idoc, one flat file has to be generated. i have used FCC with variable substitution method.
    structure is something like this
    <TOItem>
      <field1>
      <field2>
    </TOItem>
    <FieldNode>
    < Filename>
    the filename value is used to generate the file name  in variable substitution. this field should not appear in the output file. so we have used
    Filenode.fieldFixedLengths = 0 and FileNode.fixedLengthTooShortHandling=Cut
    with this 2 blank lines are being inserted in the output file.
    these lines should not appear in the output file. can anyone guide me how to achive.
    Best Regards
    Deepika

    Do not add this as a separate node. Keep it inside the field strucuture at the end and mentione the length of the field 0. Your problem will be solved.
    VJ

  • Multiple languages in flat file

    HI,
    I m trying to load data throw flat file, how i can load the multiple languages into bw. i  mean spliting in bw.
    while loading throw r/3 data , one check box will be enable in bi side ( multiple languages), what about flat file.

    hi,
    I m not asking where i have to maintain language in flat file ? i m asking while extracting the flat file data, we can see one multiple language option, it's disable mode in flate file, i given in flat file EN,GE it's have split in bw side, for unicode testing...

  • Multiple idoc to flat file

    Hi,
    i have  a scenario from idoc to flat file.There is two idoc that send message in same file.Without flat file content messages come succesfully.the format should be following:
    at the first  row should be the first idoc,
    at the second row should be the second idoc
    01  1FONEX0045               FONEX0045               FONEX SIVI SABUN 400+850ML FLOWERS                    =>1.idoc
    02  1FONEX0045               8691988000162           8691988000162                                                             =>2.idoc
    01  1DOVE0199                DOVE0199                   DOVE SAC DOKULMELERINE COZUM SAC BAKIM M     =>1.idoc
    02  1DOVE0199                8718114638348           8718114638348                                                               =>2.idoc
    Thanks in Advance
    Nurhan

    Hi,
    You have to MessageTransformBean Module.
    The MessageTransformBean module enables conversion of XML files to flat files and vice versa. You can use this module in the sender and receiver communication channels.
    In receiver communication channel, specify MessageTransformBean module before standard adapter module CallSapAdapter and use
    Module Name: localejbs/AF_Modules/MessageTransformBean
    Module Key : XML2Plain
    Please see the below links, it might be useful to you.
    /people/gabrielsagayaselvam.panneerselvam/blog/2009/12/07/standard-adapter-framework-modules-afmodules-in-pi-71-150part-2
    http://help.sap.com/saphelp_nw04/helpdata/en/24/4cad3baabd4737bab64d0201bc0c6c/frameset.htm
    Regards,
    P.Rajesh

  • How to load 2 fields out of 3 from flat file to Oracle in one interface?

    Hi,
    Is there any way to selectively load flat file into oracle within one interface. For example if my flat file has this structure:
    test_cid
    test_ind
    test_data
    and my table is:
    test_code ( correspond to test_cid above)
    test_data (correspond to test_data above)
    That can be done with two interfaces ( first to load the file into oracle staging and second to load the target oracle table from staging oracle table). Is there a way to make it in one interface?
    Edited by: vzaslav on Oct 21, 2009 1:26 PM

    That works for small tables. For big tables you need to accomodate for extra space as you will need to have at least twice as much space for working/integration tables and that is what we are trying to avoid.
    In fact I was able to modify the LKM to load the file into oracle, however my integration step fails and I cannot make it work. To make lkm work one need to change getColList in create working table/generate ctl file steps to getSrcColList. That will create the working table based on source file structure and not on target table structure.
    That doesn't work for IKM however. Any ideas would be appreciated.
    Thank You.

  • Commenting out code in TrueCode mode deletes code

    We used RoboHelp X3 and was trying to comment out specific
    sections of a code by moving over to the True Code view and
    commenting them out following the usual HTML standards/conventions.
    However, we found that when we saved the project, generated the
    file, and opened the topic(s) from the source project next time,
    the sections that we had commented out had actually got deleted.
    Could you please help me with this? Is there a specific way to
    comment out code in RoboHelp?

    (I began the earlier reply before I knew what I wanted to
    say).
    Is it possible that when those particular lines are commented
    out, the result is a syntax error in the remaining html or js code?
    Also, consider that html and js code techniques have come a
    long way since X3. Maybe your code is technically correct now, but
    X3 doesn't know it.
    Good luck.
    Harvey

  • JDeveloper wont start without commenting out setjavahome in jdev.conf

    Jdeveloper crashes on start. Running jdev.exe in console I get a "Duplicate handle failed" error from java. If I edit the jdev.conf and comment out the line SetJavaHome.... then Jdeveloper will start after being prompted to find java.exe. Tried uninstalling/reinstalling. Any suggestions appreciated:
    Environment Variables - JAVA_HOME:
    C:\Program Files\Java\jre6
    jdeveloper/jdev/bin/jdev.conf:
    SetJavaHome C:\oracle\Middleware\jdeveloper\jdk

    Please don't post grepped log output - grepping can be useful if you know what you are looking for - but if you knew what to look for you wouldn't be posting here.  Please post the full log (or put it on a file-sharing site and post the link to it).
    The output you have posted indicates that X exited successfully.  The most common cause of this is an empty (or faulty) ~/.xinitrc.  Do you use startx/xinit or how do you start X?  What is in your xinitrc?
    Also, could you elaborate on which ATI drivers you are using?  Do you have the open source xf86-video-ati or one of the closed-source options?  If this is xf86-video-ati, why do you have an xorg.conf at all, it shouldn't be needed?  If, instead, this is a closed-source driver, where did you get the content for the xorg.conf?

  • With header line & with out header line ?

    what is difference between with header line & without header line ?

    When you create an internal table object you can also declare a header line with the same name. You can use the header line as a work area when you process the internal table. The ABAP statements that you use with internal tables have short forms that you can use if your internal table has a header line. These statements automatically assume the header line as an implicit work area. The following table shows the statements that you must use for internal tables without a header line, and the equivalent statements that you can use for internal tables with a header line:
    Operations without header line
    Operations with header line
    Operations for all Table Types
    INSERT <wa> INTO TABLE <itab>.
    INSERT TABLE ITAB.
    COLLECT <wa> INTO <itab>.
    COLLECT <itab>.
    READ TABLE <itab> ... INTO <wa>.
    READ TABLE <itab> ...
    MODIFY TABLE <itab> FROM <wa> ...
    MODIFY TABLE <itab> ...
    MODIFY <itab> FROM <wa> ...WHERE ...
    MODIFY <itab> ... WHERE ...
    DELETE TABLE <itab> FROM <wa>.
    DELETE TABLE <itab>.
    LOOP AT ITAB INTO <wa> ...
    LOOP AT ITAB ...
    Operations for Index Tables
    APPEND <wa> TO <itab>.
    APPEND <itab>.
    INSERT <wa> INTO <itab> ...
    INSERT <itab> ...
    MODIFY <itab> FROM <wa> ...
    MODIFY <itab> ...
    Using the header line as a work area means that you can use shorter statements; however, they are not necessarily easier to understand, since you cannot immediately recognize the origin and target of the assignment. Furthermore, the fact that the table and its header line have the same name can cause confusion in operations with entire internal tables. To avoid confusion, you should use internal tables with differently-named work areas.
    The following example shows two programs with the same function. One uses a header line, the other does not.
    With header line:
    TYPES: BEGIN OF LINE,
    COL1 TYPE I,
    COL2 TYPE I,
    END OF LINE.
    DATA ITAB TYPE HASHED TABLE OF LINE WITH UNIQUE KEY COL1
    WITH HEADER LINE.
    DO 4 TIMES.
    ITAB-COL1 = SY-INDEX.
    ITAB-COL2 = SY-INDEX ** 2.
    INSERT TABLE ITAB.
    ENDDO.
    ITAB-COL1 = 2.
    READ TABLE ITAB FROM ITAB.
    ITAB-COL2 = 100.
    MODIFY TABLE ITAB.
    ITAB-COL1 = 4.
    DELETE TABLE ITAB.
    LOOP AT ITAB.
    WRITE: / ITAB-COL1, ITAB-COL2.
    ENDLOOP.
    Without header line:
    TYPES: BEGIN OF LINE,
    COL1 TYPE I,
    COL2 TYPE I,
    END OF LINE.
    DATA: ITAB TYPE HASHED TABLE OF LINE WITH UNIQUE KEY COL1,
    WA LIKE LINE OF ITAB.
    DO 4 TIMES.
    WA-COL1 = SY-INDEX.
    WA-COL2 = SY-INDEX ** 2.
    INSERT WA INTO TABLE ITAB.
    ENDDO.
    WA-COL1 = 2.
    READ TABLE ITAB FROM WA INTO WA.
    WA-COL2 = 100.
    MODIFY TABLE ITAB FROM WA.
    WA-COL1 = 4.
    DELETE TABLE ITAB FROM WA.
    LOOP AT ITAB INTO WA.
    WRITE: / WA-COL1, WA-COL2.
    ENDLOOP.
    The list, in both cases, appears as follows:
    1 1
    2 100
    3 9
    The statements in the program that does not use a header line are easier to understand. As a further measure, you could have a further work area just to specify the key of the internal table, but to which no other values from the table are assigned.
    Internal table with header line
    you can use anywhere except obkect oriented concept.
    Internal table without header line :
    You should use in Object oriented concept..
    Always try to use without header line,performance point of view it is best..
    Example :
    Without header line.
    Structure
    types : begin of ty_itab ,
    matnr type mara-matnr,
    end of ty_itab.
    Internal table
    data i_itab type standard table of ty_itab .
    Work area
    data wa_itab like line of i_itab
    With header line
    data : begin of i_itab occurs 0,
    matnr like mara-matnr,
    end of i_itab
    itab with header lines are obsolete, anyway it will work but not recommended. instead use work area or more effiecient is field symbols. so donot use itab with header line.
    i will explain use of itab w/o header line.
    Data: itab1 type standard table of mara with header line occurs 0,
            itab2 type standard table of mara,
            wa_itab2 type mara.
    loop at itab1.
    "This will work fine.
    endloop.
    loop at itab2.
    "This will give erro that itabd does not hav workarea
    endloop.
    "so write
    loop at itab2 into wa_itab2.
    "This will work
    endloop.
    <b>The difference between
    whih header line and with out heater line of internal table.
    ex:-
    a) Data : itab like mara occurs 0 with header line.
    b) Data: itab like mara occurs 0.
    -While adding or retrieving records to / from internal table we have to keep the record temporarily.
    -The area where this record is kept is called as work area for the internal table.
    -The area must have the same structure as that of internal table. An internal table consists of a body and an optional header line.
    -Header line is a implicit work area for the internal table. It depends on how the internal table is declared that the itab will have the header line or not.
    a) Data : itab like mara occurs 0 with header line.
    table is with header line
    b) Data: itab like mara occurs 0.
    table is without header line</b>
    regards,
    srinivas
    <b>*reward for useful answers*</b>

  • Text Fields of an External Content Type come across as Multiple Line of Text

    In SharePoint 2013 I have an external content type that consists of a couple of short (nvarchar)  fields (no more that 15 characters). When I use this ECT in a custom list the fields from the ECT end up as a "Note" type instead of "Text".
    I am not sure how this happens. I have verified this by accessing the list via poweshell where I see the Type being as "Note" and also the SchemaXml showing the colName attribute as "ntext".
    The strange thing is that initially when I created the web application and built my lists this was working.
    Any ideas or pointers would be appreciated.
    Thanks

    Hi,
    Based on your description, my understanding is that When you use the ECT in a custom list the fields from the ECT end up as a "Note" type instead of "Text".
    Have you ever changed column types from "Single line of text" to "Multiple Lines of Text" in list?http://www.sharepointdiary.com/2013/09/change-column-type-in-list-using-powershell.html
    External content types are made up of fields whose types are a subset of the primitive types of .NET. For each such .NET type, a rudimentary mapping to SharePoint’s field controls exists, describing a field’s visual appearance. Fields of type string for
    instance will, on the new and edit forms, render as a single-line text field.
    Besides, check whether the following link is useful:
    https://social.technet.microsoft.com/Forums/sharepoint/en-US/0fcb5a9f-8445-4a37-9e60-ac5e9e14e8f1/sharepoint-designer-external-content-type-shows-single-line-text?forum=sharepointgeneralprevious
    Best Regards,
    Lisa Chen
    Forum Support
    Please remember to mark the replies as answers if they help and unmark them if they provide no help. If you have feedback for TechNet Subscriber Support, contact
    [email protected]
    Lisa Chen
    TechNet Community Support

  • Changing Ship-To Parties for Multiple Line Items

    Hello!  I am wondering if there is a way to change the Ship-To party on a sales order at the line item, besides changing each line individually.  Is there a more efficient way to change the Ship-To party for multiple line items?  We are looking at creating a fast-change transaction to allow users to change the Ship-To party at the line item level for multiple lines.  Our particular transaction will make changes by delivery group.  Does anyone know if SAP version 6.0 will have functionality to allow users to change the Ship-To party for multiple lines at one time?  Thanks!

    HI ,
    Go to tcode MASS, enter the object BUS2032, then execte-enter, now select the mass odrer item data. Here u can change the req fields.
    cheers
    reward if helpful

  • Problem while commenting block of lines in impl. enhancement

    Hello,
    I am finding a problem when I am commenting block of lines in 1 implicit enhancement. I have to comment it line by line.
    WHich is very tedious.
    Is there any way to do it?
    rgds,
    Rupali

    choose all the lines, and simply comment them. A known problem is with the last line, so comment all the lines except the last one, then comment the last one

Maybe you are looking for

  • PE7 Won't Open PE3 Files

    I've just moved from PE3 to PE7 and for the most part I'm having mixed results. One problem has occurred. Of the 27 prel files created with PE3 that I have, five of them fail to open with PE7. I get the following error message: "Sorry, a serious erro

  • Push button not active in sales order Display trasaction

    Hello, I added a push button to sales order item -> additional data B tab. The push button is INACTIVE when i see via VA03 transaction where as ACTIVE if i see via VA02 transaction. My requirement is that i have to make it active VA03 Transactions al

  • Time Machine - ambiguous error message, cannot backup

    I've been without use of Time Machine for sometime (months) now.  I've been getting the following error: My backup drive (Seagate FreeAgent GoFlex - 320GB) was a attached to my Airport Extreme, but in desperation I moved it to being directly attached

  • Connecting Laptop to Printer Problem

    Have been trying to connect my laptop through the router to the printer that is connected to my PC via a USB cable. Have set up the printer properties on the PC to share the printer. Have been unable to set up a connection from my laptop to the print

  • USA, Belle Refresh, and N8

    I have an N-8, product code: 059C8T6 I'm trying to get Belle Refresh on it. I live in the US, and bought it here unlocked..... I'm on AT&T at the moment. Nokia's site is showing that the software version should be 111.040.1511. I'm showing 111.030.06