May 2018
Beginner
332 pages
7h 28m
English
The ed utility is a basic type of editor. We can edit text files using this editor:
#!/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
$ chmod u+x here_05.sh
$ ./here_05.sh
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.