- sed s/day/night/
new
- sed s/day/night/ old >new
- echo day | sed s/day/night/
I didn't put quotes around the argument because this example didn't need them. If you read my earlier tutorial, you would understand why it doesn't need quotes. However, I recommend you do use quotes. If you have meta-characters in the command, quotes are necessary. And if you aren't sure, it's a good habit, and I will henceforth quote future examples to emphasize the "best practice." Using the strong (single quote) character, that would be:
- sed 's/day/night/'
new
- echo Sunday | sed 's/day/night/'
new
There are four parts to this substitute command:
s Substitute command /../../ Delimiter day Regular Expression Pattern Search Pattern night Replacement stringThe search pattern is on the left hand side and the replacement string is on the right hand side.
We've covered quoting and regular expressions.. That's 90% of the effort needed to learn the substitute command.
No comments:
Post a Comment