1.    14 Mar 2007 #1
    Did Guest

    Removing lines from a text file


    Hi all,
    I want to remove line from txt file, exectly like i write line with
    out-file
    how can i do so ?

    Thanks

      My System SpecsSystem Spec

  2.    14 Mar 2007 #2
    RichS Guest

    RE: Removing lines from a text file


    I think you will need to read the file into PowerShell and check line by line
    for the file you want to remove - the rest of the file can be written back to
    a file
    --
    Richard Siddaway
    Please note that all scripts are supplied "as is" and with no warranty
    Blog: http://richardsiddaway.spaces.live.com/
    PowerShell User Group: http://www.get-psuguk.org.uk


    "Did" wrote:

    > Hi all,
    > I want to remove line from txt file, exectly like i write line with
    > out-file
    > how can i do so ?
    >
    > Thanks
    >
    >

      My System SpecsSystem Spec

  3.    14 Mar 2007 #3
    Jean Guest

    Re: Removing lines from a text file


    > Hi all,
    > I want to remove line from txt file, exectly like i write line with
    > out-file
    > how can i do so ?
    >
    > Thanks


    ie (remove the third line of u:\testfile.txt) :

    $f=${u:\testfile.txt}
    $f[2]=$null
    ${u:\testfile.txt}=$f

    Regards,

    --
    Jean - JMST
    Belgium


      My System SpecsSystem Spec

  4.    15 Mar 2007 #4
    Jacques Barathon [MS] Guest

    Re: Removing lines from a text file


    "Did" <didi10000@walla.co.il> wrote in message
    news:1173872693.838623.24650@d57g2000hsg.googlegroups.com...
    > Hi all,
    > I want to remove line from txt file, exectly like i write line with
    > out-file
    > how can i do so ?


    If you want to remove lines matching some specific text (e.g. "bouh"), you
    can write this:

    (type myfile.txt) -notmatch "bouh" | out-file mycleanfile.txt

    "bouh" can be any regular expression so you really have great control over
    your filter here.

    Hope that helps,
    Jacques

      My System SpecsSystem Spec


Similar Threads
Thread Forum
Using lines in a text file
I have a text file with names of applications such as Agent, E-Notify, etc. I read the content of the file with Get-Content. I want to use the...
PowerShell
Howto: Add lines of text from a specific point in a text file..
Hi all, I wonder if you can help me... I have been doing allot of manual updates to ini files that i am using and would like to make things a...
VB Script
get the number of lines in a text file
What is the command to get only the number of lines in a text file
PowerShell
Clear-Content Cmdlet and Processing Lines in Text File
I would like to use PowerShell to remove lines in a Text file that is formatted with several columns. I would like to remove lines in the file up...
PowerShell
Removing lines from a text file by matching against substrings
Hello everyone. I'm approaching this as my first powershell script in trying to both accomplish something and learn a little powerscript in the...
PowerShell
return only certain lines from large text file
I am trying to put together a scipt that will only return certain lines based on content in that line to an output file. The file we have is one...
PowerShell
removing first three lines in a text file
I have a 10mb text file and instead of doing get-contents set-contents i would like to just remove the first 3 lines of the text file. Is there a...
PowerShell

Our Sites
  • Ten Forums
  • Eight Forums
  • Seven Forums
  • PC Help Forum
  • Help Me Bake
  • Site Links
  • Contact Us
  • Privacy and Cookies
  • About Us
    Windows Vista Forums is an independent web site and has not been authorized, sponsored, or otherwise approved by Microsoft Corporation. "Windows 10" and related materials are trademarks of Microsoft Corp.

    Designer Media Ltd
    All times are GMT -5. The time now is 05:05.
    .