Windows Vista Forums
Vista Forums Home Join Vista Forums Windows 7 Forum Vista Tutorials Tags
Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks.

Go Back   Vista Forums > Misc Newsgroups > PowerShell

Vista - Removing lines from a text file

Reply
 
Old 03-14-2007   #1 (permalink)
Did


 
 

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
Old 03-14-2007   #2 (permalink)
RichS


 
 

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
Old 03-14-2007   #3 (permalink)
Jean


 
 

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
Old 03-15-2007   #4 (permalink)
Jacques Barathon [MS]


 
 

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
Reply

Thread Tools


Similar Threads
Thread Forum
Using lines in a text file PowerShell
Howto: Add lines of text from a specific point in a text file.. VB Script
get the number of lines in a text file PowerShell
Removing lines from a text file by matching against substrings PowerShell
removing first three lines in a text file PowerShell


Vista Forums is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media Ltd

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46