Skip to main content
6 of 7
Rollback to Revision 4
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 ' "${words[@]^}"
    echo
done < file

Output:

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