官术网_书友最值得收藏!

Pattern matching with the vi editor

To learn about pattern matching, we will ensure that the pattern that we will search for is highlighted when the pattern searched for is found. The configuration file for vi is /etc/vimrc.In the vi editor, use the following commands for various options:

The following is an example of a regular expression for replacing Tom with David:

:1,$s/tom/David/g                // from line 1 to end ($), replace tom by David 
:1,$s/<[tT]om>/David/g   // start and end of word   <    > 

This is another example of a regular expression. Create the love.txt file, as follows:

Man has love for Art
World is full of love
Love makes world wonderful
love looove lve
love
Love love lover loves
I like "Unix" more than DOS
I love "Unix"/
I said I love "Unix"
I love "unix" a lot

Use the following commands for testing pattern-searching facilities:

主站蜘蛛池模板: 自治县| 治多县| 平舆县| 萨迦县| 康定县| 甘南县| 芜湖市| 墨脱县| 南开区| 宁阳县| 裕民县| 嘉祥县| 都匀市| 晴隆县| 桦南县| 桐柏县| 前郭尔| 南昌市| 凌海市| 漳平市| 唐河县| 克山县| 白城市| 海林市| 通河县| 开原市| 塔河县| 灵石县| 龙山县| 成都市| 新干县| 东明县| 囊谦县| 鹿邑县| 贺兰县| 瓦房店市| 多伦县| 南郑县| 平度市| 石家庄市| 新和县|