Afficher un message
Vieux 04/11/2006, 21h14   #10
Mitch
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: splitting words into individual characters

Janis Papanagnou wrote:
> Mitch wrote:
>> Mitch wrote:
>>
>>> Janis Papanagnou wrote:
>>>
>>>> Mitch wrote:
>>>>
>>>>> Hello again.

>>
>> [...]
>>
>>>>> Mitch.

>>
>> [...]
>>
>>>> If you just want to process a single file then omit the condition...
>>>>
>>>> ls -l filename | awk '{split($1,a,""); for(i=1;i<=10;i++) print
>>>> a[i]}'
>>>>
>>>>
>>>> Janis
>>>
>>>
>>> Thank you, that worked perfectly. It forced me to learn a bit more
>>> awk than I had, but that's no bad thing. Cheers!

>>
>>
>> Hopefully a quick one...
>>
>> This prints the array, but with a newline after each character. What I
>> was hoping for, and have tried extensively is below:
>>
>> ls -l | awk '{split($1,a,""); for(i=2;i<=10;i++) print -n a[i]}'
>>


[...]

>>
>> putting the -n option after print i though removed the newline, but
>> instead it adds a zero to the beginning of every line. I thought i
>> could use sed s/ to replace the newlines with tabs or spaces, but it
>> appears that this is virtually impossible as well.
>>
>> Any ideas?

>
> In awk there are no "options to commands", thus no '-n'. Use printf,
> instead (as in the C language)...


i remember now, I'm thinking of echo.

>
> printf("%s ", a[i]);
>
> ...or whatever format specifier is best for your needs.
>


Thanks! I'll confess now I think i have the sed version down, I'm gonna
use that, but thank you very much nonetheless.

> Janis
>
>>
>> Thanks again!


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