Skip to main content
7 of 7
added 3 characters in body
Gilles Quénot
  • 36.7k
  • 7
  • 74
  • 97

One solution using , not restricted to only `foo-bar`

$ cat file
aaa-zzz-eee-rrr
foo-bar

code

$ perl -ne 'print join " ", map { ucfirst } split /-/' file
Aaa Zzz Eee Rrr
Foo Bar

Another solution using pure bash

while IFS='-' read -r -a words; do
    printf '%s\n' "${words[@]^}" | paste -sd ' '
done < file

Output:

Aaa Zzz Eee Rrr 
Foo Bar
Gilles Quénot
  • 36.7k
  • 7
  • 74
  • 97