• Day 7 文件管理补充和练习 File management & exercises


    Day 7 文件管理补充和练习 File management & exercises

    Regular expression 正则

    ^

    Beginning of line 行首

    $

    End of line 行末

    .

    Single Character 单个字符

    *

    Zero or more Occurrences 左边的字符出现0次或更多次

    +

    One or more Occurrence 左边的字符出现一次或更多次

    Zero or one Occurrence 昨天的字符出现0次或1次

    []

    [0-9]

    The character class is nothing but a list of characters mentioned within a square bracket; this is used to match only one out of several characters.任意一位数字

    [a-z] [a-Z]

    Within the square bracket, you can use a hyphen you can specify a range of characters. For example, [0123456789] can be represented by [0-9], and alphabetic ranges can be specified such as [a-z],[A-Z] etc.

    任意一个小写字母/大写或小写字母

    [^]

    ^在中括号里表示“非”的意思

    |

    OR Operation 表示“或”

    {}

    {m}

    Exactly M Occurrences 表示出现了m次

    {m,n}

    M to N Occurrences 表示出现了m到n次

     

    AWK

    awk -Fs '/pattern/ {action}' input-file

    AWK exercises

    打印uid在30~40范围内的用户名。
    awk -F: '$3>=30 && $3<=40 {print $0}' /etc/passwd
    打印第5-10行的行号和用户名
    awk -F: 'NR>=5 && NR<=10 {print NR,$1}' /etc/passwd
    打印奇数行
    awk -F: 'NR%2==1' /etc/passwd
    打印偶数行
    awk -F: 'NR2%==0' /etc/passwd
    打印字段数大于5的行
    awk -F: 'NF>5 {print $0}' /etc/passwd
    打印UID不等于GID的用户名
    awk -F: '$3!=$4 {print $0}' /etc/passwd
    打印没有指定shell的用户
    awk -F: '$NF~ /nologin$/{print $1}' /etc/passwd


    打印1..1000以内的7的倍数和包含7的数

     

  • 相关阅读:
    使用binlog日志还原数据详解
    js自定义双击函数
    部署全局ajax处理
    mysql开启binlog日志和慢查询日志
    iOS-静态库,动态库,framework浅析(三)
    iOS-静态库,动态库,framework浅析(二)
    ios-静态库,动态库,framework浅析(一)
    iOS
    xcode工程编译错误:The maximum number of apps for free development profiles has been reached.
    iOS
  • 原文地址:https://www.cnblogs.com/fengshili666/p/14118882.html
Copyright © 2020-2023  润新知