Linux Base entry three week job "Linux Micro Jobs"

Source: Internet
Author: User
Tags locale

1. Display all files or directories in the/var directory that start with L, end with a lowercase letter, and have at least one digit (can have other characters) appear in the middle.

ls-d/var/l*[0-9]*[[:lower:]] or ls-d/var/l*[[:d igit:]]*[[:lower:]]

Command test results

[Email protected] desktop]# touch/var/l0a/var/la1ab/var/lab2abc[[email protected] desktop]# ls-d/var/l*[0-9]*[[:low Er:]]/var/l0a/var/la1ab/var/lab2abc[[email protected] desktop]# ls-d/var/l*[[:d igit:]]*[[:lower:]]/var/l0a/var/la 1ab/var/lab2abc



2. Displays files or directories that start with any number in the/etc directory and end with a non-numeric number.

ls-d/etc/[0-9]*[^0-9] or ls-d/etc/[[:d igit:]]*[^[:d igit:]]

Command Test and Results

[[email protected] desktop]# Touch/etc/[email protected]/etc/1#bb[[email protected] desktop]# ls-d/etc/[0-9]*[^0-9]/e Tc/[email protected]/etc/1#bb[[email protected] desktop]# ls-d/etc/[[:d igit:]]*[^[:d igit:]]/etc/[email protected]/E Tc/1#bb



3, Show/etc directory, start with a non-letter, followed by a letter and any other arbitrary length of any character file or directory.

ls-d/etc/[^a-za-z][a-za-z]* or ls-d/etc/[^[:alpha:]][[:alpha:]]*

Command Test and Results

[Email protected] desktop]# touch/etc/[email protected]/etc/#z3c4D [[email protected] desktop]# ls-d/etc/[^a-za-z][a- Za-z]*/etc/[email protected]/etc/[email protected]/etc/#z3c4D [[email protected] desktop]# ls-d/etc/[^[:alpha:]][[:a Lpha:]]*/etc/[email protected]/etc/[email protected]/etc/#z3c4D



4. In the/tmp directory, create a file that starts with Tfile, followed by the current date and time, with a filename such as: tfile-2016-05-27-09-32-22.

touch/tmp/tfile-$ (date +%f-%h-%m-%s) or touch/tmp/tfile-' Date +%y-%m-%d-%h-%m-%s '

Command Test and Results

[Email protected] desktop]# touch/tmp/tfile-$ (date +%f-%h-%m-%s) [[email protected] desktop]# touch/tmp/tfile-' Date +% y-%m-%d-%h-%m-%s ' [[email protected] desktop]# ls/tmp/tfile*/tmp/tfile-2017-05-12-09-50-18/tmp/ Tfile-2017-05-12-09-50-23



5. Copy all the files or directories in the/etc directory to the/tmp/mytest1 directory that begin with P and do not end with a number.

Cp-r/etc/p*[^0-9]/tmp/mytest1 or cp-r/etc/p*[^[:d igit:]]/tmp/mytest1

Command Test and Results

[[email protected]alhost desktop]# mkdir -p /tmp/mytest1 ; cp -r  /etc/p*[^0-9] /tmp/mytest1 ; ls /tmp/mytest1pam.d    pbm2ppa.conf   plymouth      popt.d   prelink.conf.d   profile.d  purplepasswd   pinforc       pm             postfix  printcap         protocolspasswd-  pki            pnm2ppa.conf  ppp      profile          pulse[[email protected] desktop]# rm -rf / tmp/mytest1 ; mkdir -p /tmp/mytest1 ; cp -r /etc/p*[^[:d igit:]] / tmp/mytest1 ; ls /tmp/mytest1pam.d    pbm2ppa.conf  plymouth       Popt.d   prelink.conf.d  profile.d  purplepasswd   pinforc        pm             postfix  printcap        protocolspasswd-   pki           pnm2ppa.conf  ppp       profile         pulse



6. Copy all files or directories ending with. D in the/etc directory into the/tmp/mytest2 directory.

Cp-r/etc/*.d/tmp/mytest2

Command Test and Results

[[email protected] desktop]# mkdir -p /tmp/mytest2 ; cp -r /etc/* .d /tmp/mytest2 ; ls /tmp/mytest2bash_completion.d  ipsec.d          profile.d      rwtab.dbinfmt.d            ld.so.conf.d    rc0.d           sane.dchkconfig.d         libibverbs.d    rc1.d           Setuptool.dcron.d             logrotate.d      rc2.d           statetab.ddepmod.d           modprobe.d       rc3.d          sudoers.ddnsmasq.d           modules-load.d  rc4.d           sysctl.ddracut.conf.d      my.cnf.d         rc5.d          tmpfiles.dexports.d           oddjobd.conf.d  rc6.d           usb_modeswitch.dgdbinit.d           pam.d           rc.d            xinetd.dgrub.d              popt.d          request-key.d   Yum.repos.dinit.d  &nbSp;          prelink.conf.d  rsyslog.d 



7. Copy all files in the/etc/directory that begin with L or M or N and end with. conf to the/TMP/MYTEST3 directory.

Cp-r/etc/[lmn]*.conf/tmp/mytest3 or Cp-r/etc/{l,m,n}*.conf/tmp/mytest3

Command Test and Results

Mkdir-p/tmp/mytest3; Cp-r/etc/[lmn]*.conf/tmp/mytest3; ls/tmp/mytest3ld.so.conf locale.conf mke2fs.conf nsswitch.conflibaudit.conf logrotate.conf mtools.conf nu mad.conflibuser.conf man_db.conf Nfsmount.confrm-rf/tmp/mytest3; Mkdir-p/tmp/mytest3; Cp-r/etc/{l,m,n}*.conf/tmp/mytest3; ls/tmp/mytest3ld.so.conf locale.conf mke2fs.conf nsswitch.conflibaudit.conf logrotate.conf mtools.conf nu mad.conflibuser.conf man_db.conf nfsmount.conf


Linux Base entry three week job "Linux Micro Jobs"

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.