AWK to print field $2 first, then field $1

后端 未结 4 1031
时光取名叫无心
时光取名叫无心 2020-12-12 20:33

Here is the input(sample):

name1@gmail.com|com.emailclient.account
name2@msn.com|com.socialsite.auth.account

I\'m trying to achieve this:

4条回答
  •  离开以前
    2020-12-12 21:16

    Use a dot or a pipe as the field separator:

    awk -v FS='[.|]' '{
        printf "%s%s %s.%s\n", toupper(substr($4,1,1)), substr($4,2), $1, $2
    }' << END
    name1@gmail.com|com.emailclient.account
    name2@msn.com|com.socialsite.auth.account
    END
    

    gives:

    Emailclient name1@gmail.com
    Socialsite name2@msn.com
    

提交回复
热议问题