The reverse of the "findstr" command in a batch file.

Hi.
I hope I'm in the right place.  I am trying to run a command/batch file on a really large text file to replace all lines of text with the exception of certain lines which contain a certain word.  I know this can be done to 'delete' certain lines
and keep the others using the "findstr" command.  What this command does is deletes all lines in a text file that contain specific words whilst keeping all other lines.
I want to do the exact opposite to this.  I want to keep certain lines of text containing specific words whilst deleting all others.
Does anyone know what this command might be?  Or is there a switch one can use with "findstr" command to do it?
All help appreciate
J

In general you could write:
(Get-Content.\inputfile.txt)
-match"keyword"|Out-File.\outputfile.txt-Encodingascii
Outputfile.txt would then contain all lines that contain "keyword".
This should work for files with a size <4GB.
I've just tried: The powershell.exe process didnt get more than 4GB RAM. :-)
Walter

Similar Messages

  • Is there any command in windows batch file similar to the unix grep command

    Hi,
    I have a batch file which will return status of the Database to a file ex: "OPEN". Now I want to read this output file and check for the "OPEN" string from another batch file. any suggestions?. This is similar to "grep" command in unix. I want this to be done in windows batch file.
    This is my actual batch file
    rem -- Description: Check whether the Database is UP
    rem -- Usage:
    rem -- ORACLE_SID is input parameter for the file
    rem --
    rem --start of batch file
    @echo off
    set ORACLE_SID=%1
    echo connect plp/ltd1plp@%1
    echo set cmdsep on
    echo set cmdsep '"'; --"
    echo set term on
    echo spool c:/status_log.log
    echo select status from v$instance;
    echo spool off
    ) | sqlplus /nolog
    rem --end batch file
    Thanks.

    The same link from [google cache|http://209.85.229.132/search?q=cache:EJrm9tgj0a8J:www.microsoft.com/resources/documentation/windows/xp/all/proddocs/en-us/find.mspx+windows+find&cd=1&hl=en&ct=clnk&client=opera]. Also you can use help:
    find /?

  • How do I write a command in a .batch file written in NOTEPAD to run a powershell command?

    How do I write a command in a .batch file written in NOTEPAD to run a powershell command?
    Example:
    powershell -Command "& {Update-Help;}"
    would this be a correct command to put in a .batch file to update help information in powershell.
    All I want to know is how to write a windows powershell command in a .batch file.
    Multi-Commands
    Single-Commands
    Charles Wright

    Hi,
    You can separate multiple commands with a semicolon (;).
    Don't retire TechNet! -
    (Don't give up yet - 13,085+ strong and growing)

  • Using a Variable to Substitute the path\filename of a Batch file in the Start_Process Command

    I am trying to write a script that will execute a batch file on a remote Windows server.
    This line below is basically what I'm trying to do and it works without error, however I would like to use a variable for the path\filename of the batch file.
    invoke-command -computername QSC-A-ICE01 -scriptblock {Start-Process "\\qsc-a-ice01\D$\Test\RunThis.bat" }
    If I try to use a variable as in this example below I receive the error below. The error seems to indicate it's it expecting a "FilePath" parameter. Is this true? How would I change this script to make it work when substituting a variable.
    $MyProcess =  "\\qsc-a-ice01\D$\Test\RunThis.bat"
    Write-Host $MyProcess
    invoke-command -computername QSC-A-ICE01 -scriptblock {Start-Process "$MyProcess"}
    This is the error text I receive when using a variable:
     PS C:\Windows\system32> D:\Test\ThisWorks.ps1
    \\qsc-a-ice01\D$\Test\RunThis.bat
    Cannot validate argument on parameter 'FilePath'. The argument is null or empty. Supply an argument that is not null or
    empty and then try the command again.
        + CategoryInfo          : InvalidData: (:) [Start-Process], ParameterBindingValidationException
        + FullyQualifiedErrorId : ParameterArgumentValidationError,Microsoft.PowerShell.Commands.StartProcessCommand
        + PSComputerName        : QSC-A-ICE01
    PS C:\Windows\system32>

    Mike,
    Thanks for providing the link, it was very informative. The link described how to use the args in a ScriptBlock and provided me with an explaination as to why it works the way it does on a remote server. This is my 1st post to the forum and I don't know
    how the points system works yet.
    I would like to split the points , but I don't see that this is possible.
    You're very welcome, I'm glad that the information was helpful.
    You can mark as many posts as answers as you'd like, there's not a restriction on only having a single answer per thread. You certainly don't have to though, David's answer is more than sufficient to help any future people who find this thread.
    Also, on a side note, you may want to post in the thread below. Posting there will get your account verified so you'll be able to post links and images.
    http://social.technet.microsoft.com/Forums/en-US/200c33c9-abe9-494a-953a-bf53fccb3c76/verify-your-account-11?forum=reportabug
    (Future people - don't use that link.
    Click here and look for the current thread as a sticky.)
    Don't retire TechNet! -
    (Don't give up yet - 12,575+ strong and growing)

  • What is the Unix command to concatenate two files and merget it in to one ?

    Hi Experts,
    I have three jobs and each job creates a file. I want to run one more job which clubs these three files and merges it in to one.
    I know the process of opening each file and appending it in to the target file using DATASET concept.
    Instead of that, I want any UNIX Shell command so that I can call that directly from ABAP and execute it
    Any help on this would be highly appreciated
    Thanks in advance.
    Babu Kilari

    Hello Babu,
    We can very well call an OS command from within ABAP, but in your case, I don't think that is really required. Please find below a logic that might be helpful to you.
    You have three files, whose contents needs to be merged into a single file.
    Read the contents of each file and store it into an internal table.
    DATA: command LIKE rs37a-line.
    DATA: BEGIN OF tabl OCCURS 0,
              line(2000),
          END OF tabl.
    command = 'cat /tmp/file1.txt'.
    CALL 'SYSTEM' ID 'COMMAND' FIELD command
                  ID 'TAB'     FIELD tabl-*sys*.
    Internal table 'tabl' will contain the contents of the file.
    Accumulate all the contents into a single file and upload to the application server using OPEN DATASET, TRANSFER DATASET and CLOSE DATASET.
    Let me know if you need a more detailed explanation.
    Regards
    Sabu.

  • Export to PDF - Can a single report (rpt file) create multiple PDF files using the export command?

    Post Author: markeyjd2
    CA Forum: Exporting
    Greetings forum members,
    My question is, in its entirety: Can a single report (rpt file) create multiple PDF files using the export command, ideally one PDF file per DB record?
    In my case; I have a Crystal Report that reads data from a DB table containing ~ 500 records.  When I export the report to a PDF file, I get one PDF file, with ~ 500 pages.
    What I would like to do is export the report to ~ 500 individual PDF files; One file per DB record.  The file names would be based on the table's primary key.
    Is this possible?

    Post Author: Micha
    CA Forum: Exporting
    Hi,
    you need some lines of code, but its easy. Dependend on how to start the generation of your 500 PDFs, you can write an ASP page and start it via Web Browser, or a Windows Script and start it via scheduled job...
    Here's an abstract of the ASP code I use:
    First, you create a recordset (here: "rsc") which gives you the list of ID fields you want to export, then you create CrystalRuntime.Application object, then you loop through the recordset, open your report (here: "oRpt") and set login info. Then set the selectionformula, so that the report displays only the data of the current ID, e.g.:
      oRpt.RecordSelectionFormula = "(" & oRpt.RecordSelectionFormula & ") AND {myTab.myVal}=" & rsc("myVal")
    Then you export the report, move to the next record in recordset, and repeat the loop until recordset.EOF. Then you close recordset and connection.
    Micha

  • Supressing the Java command window ???

    Hi,
    How do I get rid of the command window from where I start my Java Application ?
    Even if there is a way what will happen to all the System.out.println() calls in my applicatio ?
    Thanks in advance.

    You can just not start the Java application from a command window or batch file. The easiest way to do this is to create an executable JAR file which a person (on Windows) can just double-click. Do a search on "executable JAR".

  • How to pass command-line options to app using the "open" command?

    I am using jedit, and since I'm doing a lot of stuff in a shell, I'd really like to launch it from the command line as though I'd opened from finder, so I wrote a script that contains this:
    open -a /Applications/Jedit.app "$@" &
    This works well for everything except NEW files, where I get this error:
    2007-02-16 19:29:48.072 open[1032] No such file: /Users/millerti/projects/ateon/new_file
    Is there a way I can override this?
    So, it occurred to me that I might try running jedit directly this way:
    /Applications/Jedit.app/Contents/MacOS/jedit -- "$@" &
    The trouble is that this suffers all sorts of weird problems. For instance, if there's already a jedit running, it launches another one (despite the fact that -server is default). Moreover, the file it opens, existing or not, is not the one I specify. If I'm in ~/mydir and I open ./myfile, jedit opens instead /Applications/myfile.
    Obviously, I'm doing something wrong. Can someone help me figure out what open is doing internally so that I can launch jedit compatible with how open does it so that I can both open existing files and create new ones the same way from the command line?
    BTW, I can make more complex script.
    Also, if this isn't the right forum for this, can someone tell me where would be a better place to get the question answered?
    And I'm not expecting to get jedit support here. This isn't a jedit problem because it's behaving correctly.
    Thanks.

    Applications rarely take command line arguments. I don't know anything about Jedit, whether that is an exception, but you are not sending an argument to Jedit with the open command. The file name on your command line is an argument to the open command. The open command says "open this file with the specified application". The application doesn't see the argument. It sees the file exactly as if it were opened from the Finder. That's why naming a non-existent file doesn't work.
    What if you open Jedit with no file, create a new document in the application. (Again, I am not familiar with Jedit.)

  • Webutil command into batch file

    Hello,
    We have a 10gR2 environment, with webutil.
    I get a weird behaviour with CLIENT_HOST.
    When I use this command
    myCommand := 'cmd /c COPY c:\file1.txt c:\toto.sql ';
    CLIENT_HOST(myCommand);
    There is no problem.When I use put the COPY command into a .bat file, in order to execute the .bat file with CLIENT_HOST ... the command doesn't make the job.
    There is no special information in the jInitiator console...
    But here is the code I'd like to write :
    myFile CLIENT_TEXT_IO.FILE_TYPE;
    myCommand VARCHAR2(1000);
    BEGIN
    myFile := CLIENT_TEXT_IO.FOPEN('c:\myBatch.bat', 'W');
    CLIENT_TEXT_IO.PUTF(myFile, 'COPY c:\file1.txt c:\toto.sql \n');
    CLIENT_TEXT_IO.FCLOSE(myFile);
    myCommand := 'cmd /c c:\myBatch.bat ';
    CLIENT_HOST(myCommand);
    END;
    Also, when I doubleClick on the myBatch.bat file under Windows, the command works fine !
    My problem is that I need to have a .bat file that gathers many commands. (this is not only about copying a file)
    What puzzles me, is that I don't have such problem with our 8i environment !
    That's why I was thinking about any special privilege/setup missing in our 10g environment / configuration...
    Any idea or advice?
    Thanks,
    Olivier

    Hi Olivier
    The problem is that the operative system hasn’t written the file yet, even though the fclose command as been executed.
    I used this type of code to check if the file is closed in the file system.
    loop
    l_counter := l_counter + 1;
    if webutil_file.file_size('c:\myBatch.bat') > 0 then
    CLIENT_HOST(myCommand);
    exit;
    end if;
    if l_counter > 100 then
    SET_ALERT_PROPERTY('UI_ERROR',alert_message_text,'Timeout. Copy can not be completed, due to file not being released by file system.' );
    l_button := show_alert('UI_ERROR');
         exit;
    end if;
    end loop;
    Hope this will help you solve the problem
    Cheers
    Nils Peter

  • Batch file command

    Hi Guys I have this batch file called via ant build script.The batch file has 10 different function .Now i have this requirement to break it into smaller parts.
    Example the functionality should now be broken into three parts
    1)employee data processing
    2)employee working days
    3)employee salary
    4)employee promotion history
    1)employee data processing
    2)employee working days
    3)employee salary
    1)employee data processing
    2)employee working days
    4)employee promotion history
    Problem is absence of OR statment in batch file will force me to write this
    command in separate batch file.(I was trying to put it into one so that I dont have to repeat statments).Basically I was trying to execute target and target will execute the batch file with a parameter,which will then decide which functionality to execute , but in absence of OR is causing me some headache.Not able to decide the best strategy.
    help
    Yang Shetling

    Maybe I missed it, but where is the Java question?

  • The problem I have since I upgraded to Mavericks version 10.9.1 The problem appears only with Mail not with other programs, not even with my browser. When I try to zoom the text of an e-mail I received or sent , I can no longer use the keys Command   to e

    the problem I have since I upgraded to Mavericks version 10.9.1
    The problem appears only with Mail not with other programs, not even with my browser.
    When I try to zoom the text of an e-mail I received or sent , I can no longer use the keys Command + to enlarge the text, although I can reduce it with Command -.
    As I have a problem with my eyes, This is a serious matter for me.
    When I write an e-mail, if I select text and press Command +, it just displaces the text to the right.
    Now, my husband has a USB keyboard. If he connects it to my computer, his regular Command + does not work either, but  he uses the extended keyboard, then it works. Unfortunately, he needs it for a musical application which does not work with a wireless keyboard.

    Firefox 3.6.4 and 3.6.6 use a process called, "plugin-container.exe" which was using up most of my CPU when I opened up multiple tabs that contained Adobe Flash files, and caused Firefox to lock up.
    My solution was to use Firefox 3.5.10 which you can get from the Mozilla website at [http://www.mozilla.com/en-US/firefox/all-older.html]
    I am using Adobe Flash 10.1.53.64 without any problem in this version of Firefox. Check the release notes, I believe it contains all the latest security fixes in "Firefox 3.6.4".
    Hopefully, they will fix Firefox 3.6 in the next version (e.g. Firefox 3.6.7), until then you should probably use "Firefox 3.5.10".

  • How do I use the a command from a .dll with labview?

    I want to use for example the M8784Open() command to control an M8784
    photon counter.  I know how to place a call library function node
    but don't know where to go there. The user manual for the photon
    counter has the following explanation of the M8784Open() command but I
    don't know how to use their advice in labview!
    7-3-1 M8784Open( )
    Declaration HANDLE M8784Open( BYTE Board );
    Parameter
    BYTE Board
    Specify the board to be used: M8784_MASTER or M8784_SLAVE. Specify both
    when making 2-channel measurements simultaneously. It is not possible
    to specify M8784_SLAVE only.
    Return value A handle for the M8784 is returned when the function has succeeded..
    INVALID_HANDLE_VALUE is returned if the function has failed..
    Explanation Calls a handle to allow the M8784API.dll to use the M8784.sys driver.
    Hereafter, specify this API’s return value (handle) when using other APIs.
    When quitting M8784 operation, call up M8784Close( ) to cancel the driver.

    You need to find out the equivalent number of the parameter. Somewhere in your documentation, or inside a file (for example, a header .h file in C/C++) you will find the definitions of each parameter.
    For example, M8784_MASTER may have the value 1 and M8784_SLAVE the value of 2. You already know that it is a BYTE, so it will be a number of type U8 in LabVIEW. You need to find the exact values.
    Probably, by value "A" it means the hex number "A", which is 10 in decimal. You need to find that in your documentation.
    You also need to find the type HANDLE. It can be a BYTE, etc. Once you know that, find the value of INVALID_HANDLE_VALUE, so you can test for the error.
    Most of this information can be found in the document Using External Code in LabVIEW. Check your help file, or check this link.
    Regards;
    Enrique
    Message Edited by Enrique on 09-29-2005 10:36 AM
    www.vartortech.com

  • Custom SharePoint 2010 designer page throws "The data source control failed to execute the insert command" exception while adding the new item after the August 13, 2013 CU has installed

    We have the SharePoint Server 2010 with SP1 environment on which the custom SP2010 designer pages were working as expected before the
    August 13, 2013 CU has installed. But, getting the below exception while trying to add the new item after the CU has installed.
    Error while executing web part: System.NullReferenceException: Object reference not set to an instance of an object.     at Microsoft.SharePoint.WebControls.SPDataSourceView.ExecuteInsert(IDictionary values)     at
    System.Web.UI.DataSourceView.Insert(IDictionary values, DataSourceViewOperationCallback callback) 3b64c3a0-48f3-4d4a-af54-d0a2fc4553cc
    06/19/2014 16:49:37.65  w3wp.exe (0x1240)                        0x1300 SharePoint Foundation        
     Runtime                        tkau Unexpected Microsoft.SharePoint.WebPartPages.DataFormWebPartException: The data source control
    failed to execute the insert command. 3b64c3a0-48f3-4d4a-af54-d0a2fc4553cc    at Microsoft.SharePoint.WebPartPages.DataFormWebPart.InsertCallback(Int32 affectedRecords, Exception ex)     at System.Web.UI.DataSourceView.Insert(IDictionary
    values, DataSourceViewOperationCallback callback)     at Microsoft.SharePoint.WebPartPages.DataFormWebPart.FlatCommit()     at Microsoft.SharePoint.WebPartPages.DataFormWebPart.HandleOnSave(Object sender, EventArgs e)    
    at Microsoft.SharePoint.WebPartPages.DataFormWebPart.RaisePostBackEvent(String eventArgument)     at System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument)     at System.Web.UI.Page.ProcessRequestMain(Boolean
    inclu... 3b64c3a0-48f3-4d4a-af54-d0a2fc4553cc
    06/19/2014 16:49:37.65* w3wp.exe (0x1240)                        0x1300 SharePoint Foundation        
     Runtime                        tkau Unexpected ...deStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) 3b64c3a0-48f3-4d4a-af54-d0a2fc4553cc
    I have tried changing the "DataSourceMode" as below, now the insert command is working, but update command is not working.
    <SharePoint:SPDataSource runat="server" DataSourceMode="ListItem" />
    Also, the lookup dropdown fields are displaying the value as "<a href="Daughterhttp://cpsp10/sites/Employees/_layouts/listform.aspx?PageType=4&ListId={8F62F444-FB6A-4F03-9522-C4696B45DCD1}&ID=10&RootFolder=*">Daughter</a>"
    instead of only "Daughter".
    Please provide the solution to get rid of this issue.
    Thanks
    Ramasubbu

    Try below:
    http://social.technet.microsoft.com/Forums/en-US/ae910269-3a0c-4506-844b-e8bc89d95b71/data-source-control-failed-to-execute-the-insert-command
    http://blog.jussipalo.com/2012/01/sharepoint-2010-data-source-control.html
    While there can be many causes for this generic error message, in my case the first parameter or ddwrt:DataBind function inside the SharePoint:FormFields element was
    'i' and I was working with an Edit Form. Changing it to
    'u' as it was with every other FormField fixed the issue.
    <SharePoint:FormField runat="server" id="ff1{$Pos}" ControlMode="Edit" FieldName="Esittaja" __designer:bind="{ddwrt:DataBind('u',concat('ff1',$Pos),'Value','ValueChanged','ID',ddwrt:EscapeDelims(string(@ID)),'@Esittaja')}"
    />
    Explanation:
    DataBind operation type parameters (the first parameter) are listed below:
    'i' stands for INSERT,
    'u' stands for UPDATE,
    'd' stands for DELETE.
    http://webcache.googleusercontent.com/search?q=cache:d9HHY4I7omgJ:thearkfloats.blogspot.com/2014/03/sharepoint-2010-data-source-control.html+&cd=4&hl=en&ct=clnk&gl=in
    If this helped you resolve your issue, please mark it Answered

  • Report with two Command is empty if one of the two commands returns no data

    Hi all,
    I have a report with two Commands not linked together.
    If ONLY one of the two Commands returns no data, the full report is empty (although the other Command returns data).
    I'm using Crystal Report 2008 and the CRJ 12.2.205
    Have an idea?

    Hi Ted,
    how can I solve the problem, please? It is important.
    If I can help yourself, the problem is appeared in many reports since I updated the library (the old library version 11.8.4.1094 works fine with all). I'm waiting for your answer, please.
    Thank you very much.

  • The pipe "|" does not work in the Windows command console.

    This is a very weird problem. I am using 64-bit Windows VISTA command window for very long time and it just suddenly do not work with the pipe character anymore. I have checked the PATH and PATHEXT in Administrator mode and they look OK.
    Detail below:
    For example, the "dir" work as expected.
    C:\newcmd>dir *.txt
     Volume in drive C has no label.
     Volume Serial Number is 4CD2-5B84
     Directory of C:\newcmd
    10/31/2014  11:33 PM               737 adder.txt
    04/05/2015  03:21 PM         1,890,696 au01.txt
    12/17/2014  10:40 PM             4,204 bintree.txt
    07/26/2011  10:47 PM         3,298,568 ke30-07-2011.txt
    If pipe to a VBScript file below, the error message shows up. The error message is actually the content of %PATHEXT% environment variable:
    C:\newcmd>dir *.txt|cscript //nologo cut.vbs -c "1-12"
    '.COM;.EXE;.BAT;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC;.REX;.REXG;.REXP;.CMD;'
    is not recognized as an internal or external command, operable program or batch file.
    The VBScript works fine without the "|":
    C:\newcmd>cscript //nologo cut.vbs
    Usage:cut "<delimiter>" "<column 0>,<column 1>,..."
    Example:cut "|" "0,1,8"
    What is going on and how to fix it? Help?
    C:\newcmd>echo %PATH%
    C:\Windows\system32;C:\Windows\System32\Wbem;C:\Program Files (x86)\CyberLink\Power2Go;C:\Program Files (x86)\Java\jre1.6.0_07\bin;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files (x86)\QuickTime\QTSystem\;C:\Program Files\nodejs\;C:\Program Files\ooRexx;c:\
    C:\newcmd>echo %PATHEXT%
    .COM;.EXE;.BAT;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC;.REX;.REXG;.REXP;.CMD;

    Hi,
    Please check if this happens in [https://support.mozilla.com/en-US/kb/Safe%20Mode Safe Mode.] Safe Mode is a temporary diagnostic feature and you can exit and start Firefox normally again. The installed '''Extensions''', themes ('''Appearance''') and '''Plugins''' are disabled in safe mode.
    [http://kb.mozillazine.org/Problematic_extensions Problematic Extensions]
    [https://support.mozilla.com/en-US/kb/Troubleshooting%20extensions%20and%20themes Troubleshooting Extensions and Themes]
    [http://support.mozilla.com/en-US/kb/Uninstalling+add-ons Uninstalling Add-ons]
    [http://kb.mozillazine.org/Uninstalling_toolbars Uninstalling Toolbars]

Maybe you are looking for

  • Keytool error: java.lang.Exception: Keystore file does not exist:

    Hi All, While listing the keystore using the command keytool -list, I got the error message that keytool error: java.lang.Exception: Keystore file does not exist: C:\Documents and Settings\subramanian.arivalag\.keystore I noticed there is no file .ke

  • Display XML forms in a single window-URGENT!!!!!!!

    Hi, I created a project with XML forms Builder. It is working but the thing is that now i just want to display all the forms in the same window. Means that when i want to edit a new item instead of a new window i want to work in the same browser. Is

  • Position of iconified JInternalFrame window

    Hi, I am attempting to "memorize" the position of a JInternalFrame window when it is iconified. However, if I use the standard getX(), getY(), getWidth() and getHeight() calls, it returns the original position of the JInternalFrame, as if it was deic

  • NI 5680 Read Error

    I am reading from a NI 5680 RF power meter in a while loop and sometimes the ni568x Read vi returns error -1073807339 which is a timeout before operation completed problem. Normally a read takes approx. 100 ms and when the error occurs it is at appro

  • BADI Development Contents

    hi can any body tell me from where i can get BADI Development contents i am new to BADI, where i can get the detailed contents regarding BADI's abhishek suppal