[Date Prev][Date Next] [Thread Prev][Thread Next]
[Thread Index]
[Date Index]
[Author Index]
Re: This question is regarding shell , sorry for posting but in urgency
- From: "sjonnalagadda" <sjonnalagadda osi-tech com>
- To: rpm-list redhat com
- Subject: Re: This question is regarding shell , sorry for posting but in urgency
- Date: Wed, 27 Aug 2003 22:42:21 +0530
Thank You
regards
J.S.Murthy
On Wed, 27 Aug 2003 12:03:06 -0400, Tristan Van Berkom wrote
> sjonnalagadda wrote:
>
> >hello all
> > I express my sincere applogies for posting this kind of stuff in rpm
> > mailing list. But can any one help
> >
> > I have a file like
> >
> > abc
> > def
> > hig
> > from:
> > cdb
> > dfdfd
> > make dev
> > solution
> > from:
> > this is test
> > case from
> >
> > i want to obtain all contentes from top to 2nd from:
> > can any onehelp in guiding me to write shell script
> > regards
> >
> >
> ############################
> #!/bin/bash
>
> file=$1
> let fromcnt = 0
>
> for i in `cat $file` ; do
> if [ "$i" -eq "from:" ]; then
> let fromcnt = $fromcnt + 1;
> fi
> if [ "$fromcnt" -eq "2" ]; then
> break;
> fi
> echo $i;
> done
> ##############################
>
> NOTE:
> if [ "$fromcnt" -eq "2" ]; then ...
>
> may be glitchy (maybe need an integer expression instead
> of a string comparison) but I'm not sure.
>
> you might not get the leading spaces on lines either:
>
> abc
> def
> hig
> from:
> cdb
> dfdfd
> make dev
> solution
>
> HTH,
> -Tristan
>
> _______________________________________________
> Rpm-list mailing list
> Rpm-list@redhat.com
> https://www.redhat.com/mailman/listinfo/rpm-list
[Date Prev][Date Next] [Thread Prev][Thread Next]
[Thread Index]
[Date Index]
[Author Index]
[]