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