loop over characters in input string using awk

前端 未结 4 464
抹茶落季
抹茶落季 2020-12-10 01:31

Believe it or not, I can\'t find the answer to what I would think would be this very basic question.

In awk, how can I loop over the input string character by charac

4条回答
  •  鱼传尺愫
    2020-12-10 01:37

    if you have gawk:

    awk '$0=gensub(/(.)/,"\\1\n","g")' file
    

    test:

    kent$  echo "I am a String"|awk '$0=gensub(/(.)/,"\\1\n","g")'
    I
    
    a
    m
    
    a
    
    S
    t
    r
    i
    n
    g
    

提交回复
热议问题