29/05/2007, 21h45
|
#11
|
|
|
Re: Finding a string in a file
apogeusistemas@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.
|
|
|
|