1. Show all files or directories in the/var directory that start with L, end with a lowercase letter, and have at least one digit in the middle
[[email protected] ~]# ls-d/var/l*[[:d igit:]]*[[:lower:]]
/var/l33a
2. Displays files or directories that start with any digit in the/etc directory and end with a non-digit
ls-d/etc/[[:gidit:]][^[:gidit:]]
3. Display a file or directory with a non-letter, followed by a letter and any character of any length, in the/etc directory
Ls-d/etc/[^[:alpha:]][[:alpha:]]*
4. Display all files or directories in the/etc directory that begin with a non-numeric end of M
Ls/etc/m*[^[:gidit:]]
5. Display all files or directories ending with. D in the/etc directory
Ls-d/ETC/*.D
6. Displays files or directories ending with. conf and beginning with m,n,r,p in the/etc directory
Ls-d/etc/[mnrf]*.conf
1, using the alias command, daily to the/etc directory of all files, backup to/testdir/under the new directory of Independence Day, and require the new directory format is BACKUPYYYY-MM-DD, the backup process is visible
Alias cpetc= ' cp-vrp/etc//testdir/date ' date+%f '
Alias cpetc= ' cp-vrp/etc//testdir/date& (date+%f)
2, first create the/testdir/rootdir directory, in the copy/root all the next file into the directory, and ask to retain the original permissions
cp-rp/root//testdir/rootdir
1, how to create/testdir/dir1/x,/testdir/dir1/y,/testdir/dir1/x/a,/testdir/dir1/x/b,/testdir/dir1/y/a,/testdir/dir1/y/b
Mkdir-p/dir1/{x,y}/{a,b}
[Email protected] ~]# tree dir1/
dir1/
├──x
│├──a
│└──b
└──y
├──a
└──b
2, how to create/testdir/dir2/x,/testdir/dir2/y,/testdir/dir2/x/a,/testdir/dir2/x/b
Mkdir-p/testdir/dir2/{x/{a,b},y}
Mkdir-p/testdir/dir2/{x,y/{a,b}}
[Email protected] ~]# tree Dir2
Dir2
├──x
└──y
├──a
└──b
3, how to create/testdir/dir3,/testdir/dir4,/testdir/dir5,/testdir/dir5/dir3,/testdir/dir5/dir4
Mkdir-p/testdir/dir{3,4,5/dir{3,4}}
[Email protected] ~]# tree TTT
Ttt
├──dir3
├──dir4
└──dir5
├──dir3
└──dir4
1. Convert the contents of the/etc/issue file into a hit encounter saved to/tmp/issue.out
[Email protected] testdir]# Cat/etc/issue | Tr ' A-Z ' A-Z ' >/testdir/xx
[email protected] testdir]# cat XX
\s
KERNEL \ r on an \m
The HOSTNAME is \ n
LOGIN TERMINAL is \l
The time is \ t
2. Convert the current system login user's information to uppercase and save to/tmp/who.out
[[Email protected] testdir]# W | Tr ' A-Z ' A-Z ' >/testdir/xx.xx
[email protected] testdir]# cat xx.xx
14:04:47 up 3:11, 3 USERS, LOAD average:0.00, 0.01, 0.05
USER TTY from [email protected] IDLE jcpu PCPU
root:0:0 10:54? XDM? 1:58 0.40S Gdm-session-worker [Pam/gdm-autologin]
ROOT pts/0:0 10:55 3:09m 0.06S 0.06s/bin/bash
ROOT pts/1 10.1.250.42 10:56 7.00S 0.84S 0.06S W
3, a Linux user to the root email, request the message titled "Help", the message content hello,i am user name, the system version is here, please help me to chech it, thanks!
[[email protected] ~]$ Mail-s "help" root << EOF
Hi
I am ' whoami '
The system version is here, please help me to chech it, thanks!
Eof
4, the/root file list is displayed as a line, and the filename is separated by a space
[Email protected] testdir]# Ls-1/root | Tr ' \ n '
anaconda-ks.cfg BC Desktop Documents Downloads file1-h initial-setup-ks.cfg Music Pictures public Templates tr Videos XX Xx1 xx2
The contents of the 5,file1 file are: 1 2 3 4 5 6 7 8 9 10 calculates the sum of all the numbers
[[email protected] testdir]# echo "1 2 3 4 5 6 7 8 9" > XX
[email protected] testdir]# cat XX
1 2 3 4 5 6 7 8 9 10
[email protected] testdir]# Cat XX | Tr ' + ' | Bc
55
6, handle string XT.L 1 jr#! $mn 2 c*/fe 3 uz 4, keep only the numbers
[email protected] testdir]# cat KKKK
XT.L 1 jr#! $mn 2 c*/fe 3 uz 4
[email protected] testdir]# Cat KKKK | tr-d [^[:alpha:]] | tr-d [^[:p UNCT:]]
1 2 3 4
Linux Learning-Exercise 2