You are here: Re: how to delete lines from text file « MsSQL Server « IT news, forums, messages
Re: how to delete lines from text file

Posted by Timo Salmi on 10/10/06 03:12

Ted Davis <tdavis@gearbox.maem.umr.edu> wrote:
> On 8 Oct 2006 21:34:22 -0700, "batman" <uspensky@gmail.com> wrote:
>>>>> i have a text file that is like:
>>>>>
>>>>> date = OCT0606
>>>>> asdf
>>>>> sdaf
>>>>> asdfasdgsdgh
>>>>> asdfsdfasdg
>>>>> START-OF-DATA
>>>>> asdfasdfg
>>>>> asdfgdfgsfg
>>>>> sadfsdfgsa
>>>>> asdfgsdfg
>>>>> END-OF-DATA
>>>>> asdfgalsdkdfklmlkm
>>>>> asdfgasdfg
>>>>>
>>>>> i need to clear everything from this file except the data between the
>>>>> START-OF-DATA and END-OF-DATA using a batcj file... elternitavly i am

> awk "{if( $0 ~ /END-OF-DATA/) f=0; if( f ) print $0; if( $0 ~
> /START-OF-DATA/) f=1}" infile > outfile

Also as below. The first is inclusive, the second exclusive

sed -n "/START-OF-DATA/,/END-OF-DATA/p" infile
sed "1,/START-OF-DATA/d" infile|sed "/END-OF-DATA/,$d"

All the best, Timo

--
Prof. Timo Salmi ftp & http://garbo.uwasa.fi/ archives 193.166.120.5
Department of Accounting and Business Finance ; University of Vaasa
mailto:ts@uwasa.fi <http://www.uwasa.fi/~ts/> ; FIN-65101, Finland
Useful script files and tricks ftp://garbo.uwasa.fi/pc/link/tscmd.zip

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация