我怎样才能使用 awk 来做到这一点。我需要双引号和受宠字符串中的每个单词都大写......
例子:
8,7,martin sanders, Executive director,,
9,8,bred simons,"manager, second career services",,
10,9,Kely bricks,ceo,,
...
所需的输出应该是这样的:
8,7,Martin Sanders, Executive Director,,
9,8,Bred Simons,"Manager, Second Career Services",,
10,9,Kely Bricks,Ceo,,
我运行这段代码:
awk -FS"\"" -v FPAT='([^, ]*)|(\"[^\"]+\")' '{OFS=","}{for (i=1; i<=NF; i++) {
if (substr($i, 1, 1) == "\"") {
len = length($i)
$i = toupper(substr($i, 2,len - 2))""tolower(substr($i, 2, len))} {print $i} }}
'
9,8,Bred Simons, "manager, Second Career Services",,
我尝试使用 FPAT 但我真的不明白它是如何工作的......但这还不够。我意识到这对于有经验的用户来说是一个简单的问题,但我对 awk 没有太多经验。请帮忙
我在这里阅读了解释