Displays all files or directories that start with 1 in the/var directory, end with a lowercase letter, and have at least one digit (which can be used by other characters) in the middle.
Command: ls-d/var/1*[0-9]*[a-z]
[Email protected] ~]# ls-d/var/1*[0-9]*[a-z]
Ls:cannot Access/var/1*[0-9]*[a-z]: No such file or directory
[Email protected] ~]# Clear
[3; J
[Email protected] ~]# ls-d/var/1*[0-9]*[a-z]
Ls:cannot Access/var/1*[0-9]*[a-z]: No such file or directory
[Email protected] ~]# Touch/var/1sfsfsfas
[Email protected] ~]# ls-d/var/1*[0-9]*[a-z]
Ls:cannot Access/var/1*[0-9]*[a-z]: No such file or directory
[Email protected] ~]# Touch/var/1sfsf4sfas
[Email protected] ~]# ls-d/var/1*[0-9]*[a-z]
/var/1sfsf4sfas
-----------------------------------------------------------------------------------
Displays files or directories that start with any number in the/etc directory and end with a non-numeric number.
Command: ls-d/etc/[[:d igit:]]*[^[:d igit:]]
[Email protected] ~]# Touch/etc/4dadasfas
[Email protected] ~]# ls-d/etc/[[:d igit:]]*[^[:d igit:]]
/etc/4dadasfas
-----------------------------------------------------------------------------------
Displays the/etc directory. A file or directory that starts with a non-letter followed by a letter and any character of any length.
Command: ls-d/etc/[^[:alpha:]][[:alpha:]]*
[Email protected] ~]# ls-d/etc/[^[:alpha:]][[:alpha:]]*
Ls:cannot access/etc/[^[:alpha:]][[:alpha:]]*: No such file or directory
[[email protected] ~]# TOUCH/ETC/{4SDSAFS,44SSADSF}
[Email protected] ~]# ls-d/etc/[^[:alpha:]][[:alpha:]]*
/etc/4sdsafs
-----------------------------------------------------------------------------------
In the/tmp directory, create a file that begins with Tfile, followed by the current date and time, with a filename such as tfile-2016-05-27-09-32-22.
Command: touch/tmp/tfile-' Date +%y-%m-%d-%h-%m-%s '
[[email protected] ~]# touch/tmp/tfile-' Date +%y-%m-%d-%h-%m-%s '
[Email protected] ~]# ll/tmp/
Total 4
-rw-r--r--. 1 root root 0 Sep 23:35 a_c
-rw-r--r--. 1 root root 0 Sep 23:35 a_d
-rw-r--r--. 1 root root 0 Sep 23:35 B_c
-rw-r--r--. 1 root root 0 Sep 23:35 b_d
Drwxr-xr-x. Root root 4096 Sep 23:40 Mylinux
-rw-r--r--. 1 root root 0 Sep 01:14 tfile-2016-09-26-01-14-20
-----------------------------------------------------------------------------------
Copy all the files or directories in the/etc directory to the/tmp/mufile directory that begin with P and do not end with a number.
Command: Mkdir/tmp/mytest1 && cp-r/etc/p*[^[:d igit:]]/tmp/mytest1
[[email protected] ~]# mkdir/tmp/mytest1 && cp-r/etc/p*[^[:d igit:]]/tmp/mytest1
[Email protected] ~]# ls/tmp/mytest1/
PAM.D pinforc pm PPP profile Pulse
passwd PKI popt.d PRELINK.CONF.D PROFILE.D Purple
Passwd-plymouth postfix PRINTCAP Protocols
-----------------------------------------------------------------------------------
Copy all files or directories ending with. D in the/etc directory into the/tmp.mytest2 directory.
Command: Mkdir/tmp/mytest2 && cp-r/etc/*.d/tmp/mytest2
[Email protected] ~]# mkdir/tmp/mytest2 && cp-r/etc/*.d/tmp/mytest2
[Email protected] ~]# ls/tmp/mytest2/
AUTO.MASTER.D INIT.D PROFILE.D SANE.D
BASH_COMPLETION.D IPSEC.D rc0.d SETUPTOOL.D
BINFMT.D LD.SO.CONF.D rc1.d STATETAB.D
CGCONFIG.D LIBIBVERBS.D rc2.d SUDOERS.D
CHKCONFIG.D LOGROTATE.D rc3.d SYSCTL.D
CRON.D MODPROBE.D rc4.d TMPFILES.D
Depmod.d Modules-load.d rc5.d Usb_modeswitch.d
DNSMASQ.D MY.CNF.D rc6.d VIRT-WHO.D
DRACUT.CONF.D ODDJOBD.CONF.D rc.d Xinetd.d
EXPORTS.D PAM.D Request-key.d YUM.REPOS.D
GDBINIT.D POPT.D RSYSLOG.D
GRUB.D PRELINK.CONF.D RWTAB.D
-----------------------------------------------------------------------------------
Copy all files in the/etc directory ending with. conf to the/tmp/mytest3 directory, starting with 1 or M or N.
Command: Mkdir/tmp/mytest3 && cp-r/etc/[l,m,n]*.conf/tmp/mytest3
[Email protected] ~]# mkdir/tmp/mytest3 && cp-r/etc/[l,m,n]*.conf/tmp/mytest3
[Email protected] ~]# LS/TMP/MYTEST3
ld.so.conf libuser.conf man_db.conf named.conf numad.conf
libaudit.conf locale.conf mke2fs.conf nfsmount.conf
libguestfs-tools.conf logrotate.conf mtools.conf nsswitch.conf
Linux File Selection