zoukankan      html  css  js  c++  java
  • curl cht.sh

    [root@master ~]# curl cht.sh/sed
    # To replace all occurrences of "day" with "night" and write to stdout:
    sed 's/day/night/g' file.txt
    
    # To replace all occurrences of "day" with "night" within file.txt:
    sed -i 's/day/night/g' file.txt
    
    # To replace all occurrences of "day" with "night" on stdin:
    echo 'It is daytime' | sed 's/day/night/g'
    
    # To remove leading spaces
    sed -i -r 's/^s+//g' file.txt
    
    # To remove empty lines and print results to stdout:
    sed '/^$/d' file.txt
    
    # To replace newlines in multiple lines
    sed ':a;N;$!ba;s/
    //g'  file.txt
    
    # Insert a line before a matching pattern:
    sed '/Once upon a time/iChapter 1'
    
    # Add a line after a matching pattern:
    sed '/happily ever after/aThe end.'
    
    [root@master ~]# curl cht.sh/grep
    # Search a file for a pattern grep pattern file # Case insensitive search (with line numbers) grep -in pattern file # Recursively grep for string <pattern> in folder: grep -R pattern folder # Read search patterns from a file (one per line) grep -f pattern_file file # Find lines NOT containing pattern grep -v pattern file # You can grep with regular expressions grep "^00" file #Match lines starting with 00 grep -E "[0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}" file #Find IP add # Find all files which match {pattern} in {directory} # This will show: "file:line my research" grep -rnw 'directory' -e "pattern" # Exclude grep from your grepped output of ps. # Add [] to the first letter. Ex: sshd -> [s]shd ps aux | grep '[h]ttpd' # Colour in red {bash} and keep all other lines ps aux | grep -E --color 'bash|$' [root@master ~]#

    [root@master ~]# curl https://cht.sh/awk
    # sum integers from a file or stdin, one integer per line:
    printf '1 2 3 ' | awk '{ sum += $1} END {print sum}'

    # using specific character as separator to sum integers from a file or stdin
    printf '1:2:3' | awk -F ":" '{print $1+$2+$3}'

    # print a multiplication table
    seq 9 | sed 'H;g' | awk -v RS='' '{for(i=1;i<=NF;i++)printf("%dx%d=%d%s", i, NR, i*NR, i==NR?" ":" ")}'

    # Specify output separator character
    printf '1 2 3' | awk 'BEGIN {OFS=":"}; {print $1,$2,$3}'

    # search for a paragraph containing string
    awk -v RS='' '/42B/' file

    # display only first column from multi-column text
    echo "first-column second-column third-column" | awk '{print $1}'
    [root@master ~]#

    [root@master ~]# curl cht.sh
          _                _         _    __                                        
      ___| |__   ___  __ _| |_   ___| |__        The only cheat sheet you need    
     / __| '_  / _ / _` | __| / __| '_        Unified access to the best       
    | (__| | | |  __/ (_| | |_ _\__  | | |/ /     community driven documentation   
     \___|_| |_|\___|\__,_|\__(_)___/_| |_/_/      repositories of the world        
                                                                                    
    +------------------------+ +------------------------+ +------------------------+
    | $ curl cheat.sh/ls     | | $ cht.sh btrfs         | | $ cht.sh lua/:learn    |
    | $ curl cht.sh/btrfs    | | $ cht.sh tar~list      | | Learn any* programming |
    | $ curl cht.sh/tar~list | |                        | | language not leaving   |
    | $ curl https://cht.sh  | |                        | | your shell             |
    |                        | |                        | | *) any of 60           |
    |                        | |                        | |                        |
    +-- queries with curl ---+ +- own optional client --+ +- learn, learn, learn! -+
    +------------------------+ +------------------------+ +------------------------+
    | $ cht.sh go/f<tab><tab>| | $ cht.sh --shell       | | $ cht.sh go zip lists  |
    | go/for   go/func       | | cht.sh> help           | | Ask any question using |
    | $ cht.sh go/for        | | ...                    | | cht.sh or curl cht.sh: |
    | ...                    | |                        | | /go/zip+lists          |
    |                        | |                        | | (use /,+ when curling) |
    |                        | |                        | |                        |
    +---- TAB-completion ----+ +-- interactive shell ---+ +- programming questions-+
    +------------------------+ +------------------------+ +------------------------+
    | $ curl cht.sh/:help    | | $ vim prg.py           | | $ time curl cht.sh/    |
    | see /:help and /:intro | | ...                    | | ...                    |
    | for usage information  | | zip lists _            | | real    0m0.075s       |
    | and README.md on GitHub| | <leader>KK             | |                        |
    | for the details        | |             *awesome*  | |                        |
    |            *start here*| |                        | |                        |
    +--- self-documented ----+ +- queries from editor! -+ +---- instant answers ---+
                                                                                    
    [Follow @igor_chubin for updates][github.com/chubin/cheat.sh]                   
    [root@master ~]# 
  • 相关阅读:
    常见面试测试要点
    怎样在 CentOS/RHEL 7/6 上安装和配置 Sendmail 服务器
    Cannot uninstall 'pyparsing'. It is a distutils installed project
    Linux下校验SHA1和MD5的方法
    Linux查看进程启动时间和运行多长时间
    sqlplus -S参数表示什么意思?
    dnspython模块报错 AttributeError: 'CNAME' object has no attribute 'address'
    CentOS7中安装pip的方法
    四则运算中遇到的一个问题
    动手动脑
  • 原文地址:https://www.cnblogs.com/liweiming/p/11249708.html
Copyright © 2011-2022 走看看