(not to be continued, in order to deal with the abominable 51cto Night audit system)
1. Copy the/etc/rc.d/rc.sysinit file to the/tmp directory and add # to the beginning of the line with at least one whitespace character in the/tmp/rc.sysinit file;
Vim Method:
:%s/^[[:space:]]\+/#&/
% is applied to each row
S is the replacement string command: S/replaces the pre-character/replacement character/
^[[:space:]] \+: match with multiple spaces at the beginning of the line, + to escape
#&: Add # before matching content. & means to join before matching content. No words to replace matches with #
Sed method:
Sed-i ' s/^[[:space:]]\+/#& '/tmp/rc.sysinit
-I edits the file directly. The remaining ibid.
2, copy/boot/grub/grub.conf to/tmp directory, delete the blank character of the beginning of the/tmp/grub.conf file;
Vim Method:
:%s/^[[:space:]]\+//
Indicates that matching content is replaced by empty, that is, the match is deleted
Sed method:
Sed-i ' s/^[[:space:]]\+//'/tmp/grub.conf
3. Remove the # and white space characters from the/tmp/rc.sysinit file that begin with # and followed by at least one white-space character
Vim Method:
:%s/^#[[:space:]]\+//
Sed method:
Sed-i ' s/^#[[:space:]]\+//'/tmp/rc.sysinit
4. Add # to the beginning of the first three lines in the/tmp/grub.conf file;
Vim Method:
: 1,3s/^/#&/
1,3:1-3 Line
/^/indicates the position of the beginning
/#&/in front of its position #
Sed method:
Sed-i ' 1,3s/^/#&/'/tmp/grub.conf
5. Change the last 0 of all enabled=0 or gpgcheck=0 in the/etc/yum.repos.d/centos-media.repo file to 1;
Sed-i-E ' s/\ (enabled\) =0/\1=1/g '-E ' s/\ (gpgcheck\) =0/\1=1/g '/etc/yum.repos.d/centos-media.repo
-e: Multi-point operation, capable of performing continuous editing actions
\ (enabled\): Takes () to intercept the matching field as a reference for subsequent operations. () to escape
\1: Represents the first match that was intercepted with () before the reference
G: Added at the end, indicates that all eligible matches in the row
6, every 4 hours to perform a backup of the/etc directory, back up to the/backup directory, save the directory named Shape etc-201608300202
7, weekly 2,4,6 backup/var/log/messages file to/backup/messages_logs/directory, save the file name like messages-20160830
8, every two hours every day to take the current system/proc/meminfo file in the beginning of all the information in the S./stats/memory.txt file
9, working days of work time, every two hours to perform the echo "Howdy"
Script Programming Exercises
10, create the directory/tmp/testdir-the current date and time;
11. Create 100 empty files in this directory: file1-file100
12. Display the user name of the user who is located in the/ETC/PASSW D file in the first even row;
13. Create 10 user user10-user19, password and user name;
14, create 10 empty files file10-file19 in/tmp/;
15. Change the file10 and the genus to user10, and so on.
Marco Linux Jobs Sixth week