Job 4:
One, wildcard practice:
1, Show/etc directory, start with a letter, followed by a non-letter and any other arbitrary length of any character file or directory;
[[email protected] fuboyuan]# ls-l/etc/[[:alpha:]]*[^[:alpha:]]
2. Display the/usr/share/man directory, all the files or directories that begin with man, followed by a number;
[[email protected] fuboyuan]# Ls-ld/usr/share/man/man[0~9]
3, copy/etc directory, so P,m,r start, and the. conf end of the file or directory to the/TMP/CONF.D directory;
[Email protected] fuboyuan]# MKDIR/TMP/CONF.D
[Email protected] fuboyuan]# cp-r/ETC/[PMR]*.CONF/TMP/CONF.D
[Email protected] fuboyuan]# LS-LD/TMP/CONF.D
Drwxr-xr-x. 2 root root 203 March 17:56/TMP/CONF.D
4, create A123, Cd6, c78m, C1 My, m.z, K, 8yu, 789 and other documents, and write the corresponding order according to the following requirements;
Note that the above files are separated by commas, and the other symbols are part of the file name;
1) display all files beginning with a or m;
[Email protected] fuboyuan]# ls-dh/etc/fuboyuan/[a,m]*
/etc/fuboyuan/a123/etc/fuboyuan/m.z
2) Displays all files that contain numbers in the file name;
[Email protected] fuboyuan]# ll-dh/etc/fuboyuan/*[0-9]*
Drwxr-xr-x. 2 root root 6 March 18:07/etc/fuboyuan/789
Drwxr-xr-x. 2 root root 6 March 18:07/etc/fuboyuan/8yu
Drwxr-xr-x. 2 root root 6 March 18:07/etc/fuboyuan/a123
Drwxr-xr-x. 2 root root 6 March 18:07/etc/fuboyuan/c1 my
Drwxr-xr-x. 2 root root 6 March 18:07/etc/fuboyuan/c78m
Drwxr-xr-x. 2 root root 6 March 18:07/etc/fuboyuan/cd6
Drwxr-xr-x. 2 root root 6 March 18:07/etc/fuboyuan/k 67
[Email protected] fuboyuan]# ll-d/etc/fuboyuan/*[[:d igit:]]*
Drwxr-xr-x. 2 root root 6 March 18:07/etc/fuboyuan/789
Drwxr-xr-x. 2 root root 6 March 18:07/etc/fuboyuan/8yu
Drwxr-xr-x. 2 root root 6 March 18:07/etc/fuboyuan/a123
Drwxr-xr-x. 2 root root 6 March 18:07/etc/fuboyuan/c1 my
Drwxr-xr-x. 2 root root 6 March 18:07/etc/fuboyuan/c78m
Drwxr-xr-x. 2 root root 6 March 18:07/etc/fuboyuan/cd6
Drwxr-xr-x. 2 root root 6 March 18:07/etc/fuboyuan/k 67
3) Displays all files that end with a number and contain white space characters in the file name;
[[email protected] fuboyuan]# ll-d/etc/fuboyuan/*[[:space:]]*[[:d igit:]]
Drwxr-xr-x. 2 root root 6 March 18:07/etc/fuboyuan/k 67
4) Displays all files in the file name that do not start with a C letter and do not end with a number;
[Email protected] fuboyuan]# ll-d/etc/fuboyuan/[^c]*[^0-9]
Drwxr-xr-x. 2 root root 6 March 18:07/etc/fuboyuan/8yu
Drwxr-xr-x. 2 root root 6 March 18:07/etc/fuboyuan/m.z
second, the pipeline and Io redirect exercise:
1, Statistics/usr/bin/the number of documents under the directory;
[Email protected] fuboyuan]# ll-a/usr/bin|wc-l
1643
2. Take out the user name and shell of the 9th to 15th user in the/etc/passwd file and save it to the/tmp/users file;
[Email protected] fuboyuan]# head-n 15/etc/passwd|tail-n 7|tee/tmp/users
Mail:x:8:12:mail:/var/spool/mail:/sbin/nologin
Operator:x:11:0:operator:/root:/sbin/nologin
Games:x:12:100:games:/usr/games:/sbin/nologin
Ftp:x:14:50:ftp User:/var/ftp:/sbin/nologin
Nobody:x:99:99:nobody:/:/sbin/nologin
SYSTEMD-BUS-PROXY:X:999:998:SYSTEMD Bus Proxy:/:/sbin/nologin
SYSTEMD-NETWORK:X:192:192:SYSTEMD Network Management:/:/sbin/nologin
3. Display all files or directories starting with. conf in/etc directory and count them;
[Email protected] fuboyuan]# ll-dh/etc/.conf*|wc-l
LS: Unable to access/etc/.conf*: No file or directory
0
4. Change all lowercase characters in the last three lines of the/etc/passwd file to uppercase, and delete all ":", "/" and numeric characters;
Tail-n 3/etc/passwd|tr ' A-Z ' A-Z ' |tr-d ": ,/0-9"
5, take out the 6th line of/etc/fstab;
[Email protected] fuboyuan]# head-n 6/etc/fstab|tail-n 1
# Accessible filesystems, by reference, is maintained under '/dev/disk '
6. Remove all files or directories starting with s in/etc directory, save the first 8 files to/tmp/start_with_s.out and carry out standard output at the same time;
[Email protected] fuboyuan]# ll-hd/etc/[s]*|head-n 8|ll-dh/etc/[[s]*|head-n 8|tee/tmp/start_with_s.out
Drwxr-xr-x. 2 root root 61 March 5 21:31/etc/samba
Drwxr-xr-x. 3 root root 4.0K March 5 21:33/ETC/SANE.D
Drwxr-xr-x. 2 root root 65 March 5 21:38/ETC/SASL2
Drwxr-xr-x. 3 root root 34 March 5 21:39/ETC/SCL
-RW-------. 1 root root 221 November 6 01:19/etc/securetty
Drwxr-xr-x. 6 root root 4.0K March 5 21:28/etc/security
Drwxr-xr-x. 5 root root 81 March 5 21:32/etc/selinux
-rw-r--r--. 1 root root 655K June 7 2013/etc/services
Third, other exercises:
1, the directory/etc back to the/backup directory, and renamed to "etc-Current date _ current time", such as etc-2013-02-26_20:46:30, required to retain the original properties of the file, keep the linked file;
[Email protected] fuboyuan]# cp-a/etc/backup/etc-' date+%f-%t '
[Email protected] fuboyuan]# ll-h/backup
Total dosage 28K
DRWX------. 4 root root 4.0K March 00:52 boot
Drwxr-xr-x. 138 root root 8.0K March 00:33 etc
Drwxr-xr-x. 139 root root 8.0K March 18:07 etc-date+%f-%t
2. Use the touch command to create the following file based on curly brace expansion: Ace ACF ACG Ade ADF ADG BCE BCF BCG BDE BDF BDG
[Email protected] fuboyuan]# Touch/etc/fuboyuan/{ace,acf,acg,adf,adg,bce,bcf,bcg,bde,bdf,bdg}.txt
[Email protected] fuboyuan]# ll-h/etc/fuboyuan
Total dosage 0
Drwxr-xr-x. 2 root root 6 March 24 18:07 789
Drwxr-xr-x. 2 root root 6 March 18:07 8yu
Drwxr-xr-x. 2 root root 6 March 18:07 A123
-rw-r--r--. 1 root root 0 March 19:04 ace.txt
-rw-r--r--. 1 root root 0 March 19:04 acf.txt
-rw-r--r--. 1 root root 0 March 19:04 acg.txt
-rw-r--r--. 1 root root 0 March 19:04 adf.txt
-rw-r--r--. 1 root root 0 March 19:04 adg.txt
-rw-r--r--. 1 root root 0 March 19:04 bce.txt
-rw-r--r--. 1 root root 0 March 19:04 bcf.txt
-rw-r--r--. 1 root root 0 March 19:04 bcg.txt
-rw-r--r--. 1 root root 0 March 19:04 bde.txt
-rw-r--r--. 1 root root 0 March 19:04 bdf.txt
-rw-r--r--. 1 root root 0 March 19:04 bdg.txt
Drwxr-xr-x. 2 root root 6 March 18:07 C1 my
Drwxr-xr-x. 2 root root 6 March 18:07 c78m
Drwxr-xr-x. 2 root root 6 March 18:07 cd6
Drwxr-xr-x. 2 root root 6 March 18:07 k 67
Drwxr-xr-x. 2 root root 6 March 18:07 m.z
This article from "Fuboyuan" blog, declined reprint!
Linux Jobs 4