Skip to main content
5 of 7
added 1 character 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
    paste -sd ' ' "${words[@]^}"
    echo
done < file

Output:

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