Saturday, June 27, 2020

SED, A Stream Editor

TEXT SUBSTITUTION:


Sample original file:
$ cat list_anime.txt
onepiece
naruto
slamdunk
dragonball
doraemon


#insert blank space at beginning of each line
$ sed 's/^/ /' list_anime.txt
 onepiece
 naruto
 slamdunk
 dragonball
 doraemon

#insert strings at beginning of each line
$ sed 's/^/Anime_/' list_anime.txt
Anime_onepiece
Anime_naruto
Anime_slamdunk
Anime_dragonball
Anime_doraemon

#insert strings at end of each line
$ sed 's/$/End/' list_anime.txt
onepieceEnd
narutoEnd
slamdunkEnd
dragonballEnd
doraemonEnd



No comments:

Post a Comment