Vim Editor Tip
1. Copy / etc/grub2.cfg to the / tmp directory and use the find replace command to delete the white space characters at the beginning of each line in the / tmp/grub2.cfg file.
2. Copy / etc/rc.d/init.d/functions to the / tmp/ directory and add a # sign at the beginning of each line that begins with a blank character with the find and replace command / etc/rc.d/init.d/functions
3. Copy / etc/init.d/functions file to / tmp directory, and replace / etc/sysconfig/init path in / tmp/functions file to / var/log.
4. Delete the # sign at the beginning of all lines in the / tmp/functions file that begin with # and are followed by at least one white space character
1. Copy / etc/grub2.cfg to the / tmp directory and use the find replace command to delete the white space characters at the beginning of each line in the / tmp/grub2.cfg file.
1. Copy / etc/grub2.cfg to / tmp directory # install-m 644 / etc/grub2.cfg / tmp # # the target exists, which is the directory Copy and keep the original name # ls-l / tmp/grub2.cfg-rw-r--r-- 1 root root 5853 Jun 11 18:37 / tmp/grub2.cfg2, / tmp/grub2.cfg as file # file / tmp/grub2.cfg / tmp/grub2.cfg: ASCII text3, and use the find and replace command to delete the white space characters at the beginning of each line in the / tmp/grub2.cfg file # vim + / ^ [[: space:]]\\ + / tmp/grub2.cfg into the file The cursor is on the first line that matches this pattern:% s @ ^ [[: space:]]\ + @ @ # sed-I's @ [[: space:]]\ + @ @ / tmp/grub2.cfg# sed-I-r's @ [[: space:]] + @ @'/ tmp/grub2.cfg# # calls the extended regular expression engine, but the metacharacters are different. When sed defaults to full-text scanning 2 and delimiting, it will also scan the full text. Just deal with the delimited line g: there are multiple matching contents in one line, replace them all, here the pattern can only match one, and there is no difference between g and g.
2. Copy / etc/rc.d/init.d/functions to the / tmp/ directory and add a # sign at the beginning of each line that begins with a blank character with the find and replace command / etc/rc.d/init.d/functions
1. Copy / etc/rc.d/init.d/functions to / tmp/ directory # cp / etc/rc.d/init.d/functions / tmp# ls-l / tmp/functions-rw-r--r-- 1 root root 15131 Jun 11 18:49 / tmp/functions2, Find and replace each line with a blank character beginning with the / etc/rc.d/init.d/functions command add a # sign:% s @ ^ [[: space:]]\ + @ # & @ # sed's @ ^ [[: space:]]\ + @ # & @'/ tmp/functions is the same as vim
3. Copy / etc/init.d/functions file to / tmp directory, and replace / etc/sysconfig/init path in / tmp/functions file to / var/log.
1. Copy the / etc/init.d/functions file to the / tmp directory # install-m 600 / etc/rc.d/init.d/functions / tmp/file.txt2, and replace the / etc/sysconfig/init path in the / tmp/functions file as / var/log:%s@/etc/sysconfig/init@/var/log@g
4. Delete the # sign at the beginning of all lines in the / tmp/functions file that begin with # and are followed by at least one white space character
:% s @ ^ #\ ([[: space:]]\ +\) @\ 1@