Skip to main content
added 3 characters in body
Source Link
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 ''%s\n' "${words[@]^}"
  | paste -sd echo' '
done < file

Output:

Aaa Zzz Eee Rrr 
Foo Bar

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

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
Rollback to Revision 4
Source Link
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 -sdprintf ''%s ' "${words[@]^}"
    echo
done < file

Output:

Aaa Zzz Eee Rrr 
Foo Bar

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

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
added 1 character in body
Source Link
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
    printfpaste '%s-sd ' ' "${words[@]^}"
    echo
done < file

Output:

Aaa Zzz Eee Rrr 
Foo Bar

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

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
added 2 characters in body
Source Link
Gilles Quénot
  • 36.7k
  • 7
  • 74
  • 97
Loading
added 12 characters in body
Source Link
Gilles Quénot
  • 36.7k
  • 7
  • 74
  • 97
Loading
added 83 characters in body
Source Link
Gilles Quénot
  • 36.7k
  • 7
  • 74
  • 97
Loading
Source Link
Gilles Quénot
  • 36.7k
  • 7
  • 74
  • 97
Loading