Afficher un message
Vieux 29/05/2007, 21h51   #12
apogeusistemas@gmail.com
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Finding a string in a file

On 29 maio, 16:45, Ed Morton <mor...@lsupcaemnt.com> wrote:
> apogeusiste...@gmail.com wrote:
> > On 29 maio, 11:31, Ed Morton <mor...@lsupcaemnt.com> wrote:

>
> >>apogeusiste...@gmail.com wrote:

>
> >>>On 28 maio, 18:37, Janis Papanagnou <Janis_Papanag...@hotmail.com>
> >>>wrote:

>
> >>>>apogeusiste...@gmail.com wrote:

>
> >>>>>On 28 maio, 12:34, Ed Morton <mor...@lsupcaemnt.com> wrote:

>
> >>>>>>Franco wrote:

>
> >>>>>>>On May 28, 2:52 pm, apogeusiste...@gmail.com wrote:

>
> >>>>>>>>Hi:
> >>>>>>>>I need search a specified string in a file, after the word
> >>>>>>>>"mounting" , like this:

>
> >>>>>>>>solaris> cat file
> >>>>>>>>netbackup, orac_ux001 backup, streaming yes, multiplexing ok ,
> >>>>>>>>mounting M00541 police enabled, data file

>
> >>>>>>>>Which awk command can I issue to extract only the "M00541" string
> >>>>>>>>inside a file ?

>
> >><snip>

>
> >>>>>>awk '{for (i=1;i<=NF;i++) if ($i == "mounting") print $(i+1)}' file

>
> >><snip>

>
> >>>>>Is there any way to limit the substring founded in 6 characters ?
> >>>>>I´m getting this:

>
> >><snip>

>
> >>>> print substr($(i+1),1,6)

>
> >><snip>

>
> >>>Thank you and sorry for my wrong example !

>
> >>If you posted an accurate example, I suspect there's an even simpler
> >>solution.

>
> >> Ed.- Ocultar texto entre aspas -

>
> >>- Mostrar texto entre aspas -

>
> > How could I substitute string "mounting" for "media id" in this
> > script ?

>
> Post some real sample input and expected output or we can't give you
> anything better than a guess.
>
> Ed.- Ocultar texto entre aspas -
>
> - Mostrar texto entre aspas -



I need find DAY128 string after "media id" string:
solaris> cat file

TIME SERVER/CLIENT TEXT
05/29/2007 15:18:35 smmtzsux001-bkp smmtzslx002 client smmtzslx002
handling
path /full_CORP_on_4fiiupcc
05/29/2007 15:18:35 smmtzsux001-bkp smmtzslx002 starting backup job
(jobid=207,827)
05/29/2007 15:18:43 smmtzsux001-bkp smmtzslx002 begin writing backup
id
smmtzslx002_1180441115, copy 1, fragment 1, to
media id
DAY128 on drive index 5

  Réponse avec citation
 
Page generated in 0,06127 seconds with 9 queries