I want to change FS in awk, but not in BEGIN. I want to print word and the letter.
awk 'BEGIN{FS=""}{print $1; FS=" ";print $1; FS=""}'
Of course it does't work. Is there any function, way to show words's letters?
I want to change FS in awk, but not in BEGIN. I want to print word and the letter.
awk 'BEGIN{FS=""}{print $1; FS=" ";print $1; FS=""}'
Of course it does't work. Is there any function, way to show words's letters?
awk is record oriented. It won't allow resetting the FS while processing the same line. Judging from the code you've written, you would like to take, e.g., this input:
First
Second
and you would want to see as output:
F
First
S
Second
One way to do that with awk:
awk '{print substr($1,1,1) ; print $1}' inputfile
F
First
S
Second