Afficher un message
Vieux 22/08/2006, 04h45   #6
Ed Morton
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Access 1st 12 charectors of a word.

Chris F.A. Johnson wrote:
> On 2006-08-22, Ed Morton wrote:
>
>>Chris F.A. Johnson wrote:
>>
>>>On 2006-08-22, Dave Kelly wrote:
>>>
>>>
>>>>I have a list that is 3 words to each line.
>>>>I know how to read the file.
>>>>I need only the first 12 character of the 3 word. This word is not
>>>>guaranteed to be 12 character long. This is where I'm stuck.
>>>>
>>>>Is there an equivalent to the old basic 'left$'? Where do I find it?
>>>
>>>
>>> To get the first 12 characters of the third word of every line:
>>>
>>>awk '{ printf "%s\n", substr($3,1,12) }'
>>>

>>
>>Actually, that'll print the first 12 characters of the 3rd string of
>>non-blanks. For the OP - what's a "word"? For example, in this context:
>>
>> Bob says "Hi!".
>>
>>is <"Hi!".> a word, or <"Hi!">, or <Hi!> or <Hi> or something else?

>
>
> Very true, but the OP did say there were 3 words per line. whatever
> a word is.
>


Right, but he didn't say if "words" were strictly space-separated (e.g.
is "space-separated" one word or 2 to the OP?).

Ed.
  Réponse avec citation
 
Page generated in 0,26493 seconds with 9 queries