Changing the first letter of every line in a file to uppercase

后端 未结 6 1613
无人及你
无人及你 2021-01-02 11:04

I need to change the first letter of every line in a file to uppercase, e.g.

the bear ate the fish.
the river was too fast.

Would become:

6条回答
  •  礼貌的吻别
    2021-01-02 11:19

    Pure bash:

    while read x ; do echo "${x^*}" ; done < inputfile > outputfile
    

    Test/demo (remove the code after done for more complete output):

    for f in a, a, á, à, ǎ, ā, b, c, d, e, e, é, è, ě, ē, f, g, h, i, i, í, ì, ǐ, ī, \
             j, k, l, m, n, o, o, ó, ò, ǒ, ō, p, q, r, s, t, \
             u, u, ú, ù, ǔ, ü, ǘ, ǜ, ǚ, ǖ, ū, v, w, x, y, and z.
    do  echo "$f foo bar." ; done | 
    while read x ; do echo "${x^*}" ; done | head -15 | tail -6
    

    Output:

    E, foo bar.
    E, foo bar.
    É, foo bar.
    È, foo bar.
    Ě, foo bar.
    Ē, foo bar.
    

提交回复
热议问题