The ed utility is a basic type of editor. We can edit text files using this editor:
- Write the script here_05.sh:
#!/bin/bash # flowers.txt contains the name of flowers cat flowers.txt ed flowers.txt << quit ,s/Rose/Lily/g w q quit cat flowers.txt
- Save the file, give the permission to execute, and run the script as follows:
$ chmod u+x here_05.sh $ ./here_05.sh
- The output is here:
Aster, Daffodil, Daisy, Jasmin, Lavender, Rose, Sunflower 59 59 Aster, Daffodil, Daisy, Jasmin, Lavender, Lily, Sunflower
In this script, we have passed the here document to a utility for editing the flowers.txt file. We replaced the word Rose with Lily.