We have a file (test.txt) below and we would like to Prepend each capital letter with a space:
$ cat test.txt
Hello.ThisIsATestFile.
$ sed "s/[A-Z]/ &/g" test.txt
Hello. This Is A Test File.
sed makes use of a special character "&" which implies the pattern found.
Similarly we could Append a sentence after the "Hello." string:
$ sed "s/Hello./&HowAreYou?/g" test.txt
Hello.HowAreYou?ThisIsATestFile.
No comments:
Post a Comment