0

This converts 'a' to 'A'.

sed 's/a/A/g' <(echo "foobar")
foobAr

This supplies the commands necessary to make each vowel upper-case:

$ cat << EOF
s/a/A/g
s/e/E/g
s/i/I/g
s/o/O/g
s/u/U/g
EOF

What I'm trying to do, is to extend the first example so as to make upper case each vowel, and using a here doc, as in the second example. Any suggestion?

Man:

sed [OPTION]... {script-only-if-no-other-script} [input-file]...

-f script-file, --file=script-file add the contents of script-file to the commands to be executed

2 Answers 2

2

You can use - with sed -f to indicate that the script should be read from standard input:

$ cat << EOF | sed -f - <(echo foobar)
s/a/A/g
s/e/E/g
s/i/I/g
s/o/O/g
s/u/U/g
EOF
fOObAr
0

In this case, tr is the appropriate solution:

$ echo foobar | tr [aeiou] [AEIOU]
fOObAr
3
  • More elegant, but this was more a case of reminding myself of some basics than... Commented Apr 5, 2023 at 22:19
  • 3
    If you use this method, you'd want to quote [aeiou] and [AEIOU] unless globbing is disabled in your shell Commented Apr 5, 2023 at 22:22
  • @Erwann I wondered if that might be the case… Commented Apr 5, 2023 at 22:32

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.