zoukankan      html  css  js  c++  java
  • shell vim

    • 添加环境变量

    export PATH=/Users/ChenQiushi/Library/Android/sdk/platform-tools:$PATH
    
    echo $PATH
    
    • shell

    a='abc'
    b=123
    echo ${a}_${b}
    • shell判断

    a=1
    b=2
    c=3
    d=4
    if [ $a -lt $a ] && [ $c = $d ]
    then
        echo 'a'
    else
        if [ $a -lt $b ]
        then
            echo 'b'
        fi
    fi
    • mv 目录太多

    find books/book_xml_* -name '*.*' -exec mv {} book_all ;
    

     

    • 正则find

    find book_xml_all -name '[1][0-9]{6}.*' -exec mv {} book_200w ;

      find . | grep  '[6]{5}.xml';

      

    • find 正则删mv

    find -E book_xml_all -regex '.*/[4-9]{5}.xml' -exec mv {} ../book_all ;
    

      

    • grep 正则

    ls -l test_d2 | grep -E "[0-9]{2}.xml"
    
    • grep排除 -v

    cnt=`ps x | grep 'python3 run' | grep -v 'grep'| wc -l`
    

      

    • 删除多目录下内容

    find book_xml_* -name '*.*' -exec rm -f {} ;
    

      

    find / -name pip 2> /dev/null
    

      

    • 查看目录下文件个数

    ls -l | grep "^-" | wc -l
    
    • 查看目录下存储大小

    du -h --max-depth=1 .
    • ** mac 查看目录存储
    du -d 1 .
    

      

    • 查看目录下的部分文件

    ll -t book_200w | head -n 100
    

      

    时间

    另外,下面三个的区别:
    -amin n  查找系统中最后N分钟访问的文件
    -atime n  查找系统中最后n*24小时访问的文件
    -cmin n  查找系统中最后N分钟被改变文件状态的文件
    -ctime n  查找系统中最后n*24小时被改变文件状态的文件
    -mmin n  查找系统中最后N分钟被改变文件数据的文件
    -mtime n  查找系统中最后n*24小时被改变文件数据的文件
    

      

    • 显示20分钟前的文件

    find ./book_xml -type f -mmin +20 -exec ls -ltr {} ;
    

      

    • 删除20分钟前的文件

    find ./book_xml -type f -mmin +20 -exec rm {} ;
    

      

    • scp 拷贝文件下文件,包括文件夹

    scp -r ubuntu@ec2-54-219-184-219.us-west-1.compute.amazonaws.com:/home/ubuntu/book_xml book_xml/
    
    •  临时scp加速

    1、sudo vim /etc/ssh/sshd_config
    # 末尾添加 !! 不安全做法
    GSSAPIAuthentication no
    Ciphers aes256-ctr,aes128-cbc,3des-cbc,aes192-cbc,aes256-cbc,chacha20-poly1305@openssh.com,aes128-ctr,aes192-ctr,aes256-ctr,aes128-gcm@openssh.com,aes256-gcm@openssh.com
    
    2、重启
    sudo service sshd restart
    

      

    scp -c aes192-cbc ubuntu@ip:/home/ubuntu/file.zip .

    •  zip

    zip -rq bcd.zip fold1 fold2
    zip -r fold.zip fold* 
    zip -rmq fold.zip fold # 压缩后,删除fold
    unzip prd.zip unzip -n prd.zip # 不覆盖已有文件 unzip -nd /tmp prd.zip # -d 目录
    •  tar

    # 最大压缩率
    tar cJf test.tar.xz test
    # 解压 tar xf test.tar.xz -C /root/

      

    使用多核压缩

    sudo apt install pigz
    yum install pigz

    tar --use-compress-program=pigz -cJf book_100w.tar.xz book_100w

    设置别名

    alias tar="tar --use-compress-program=pigz"

    # 压缩率
    env GZIP=-9 tar czf file.tar.gz /path/to/directory

    # 解压
    tar xzf file.tar.gz -C "/root/path"

      

    • vim 全局替换

    :%s/old/new/g
    
    • vim配置 sudo vim /etc/vim/vimrc
    # sudo vim /etc/vim/vimrc
    syntax on set nu! set autoindent set tabstop=4

    第几行:1gg

    跳到文本的最后一行:G

    shift+6 行首  或 0

    $行末
    o:在当前行下面插入一个新行
    O:在当前行上面插入一个新行

    上:k nk:向上移动n行 9999k或gg可以移到第一行 G移到最后一行
    下:j nj:向下移动n行
    左:h nh:向左移动n列
    右:l nl:向右移动n列

    复原

    u 会删除到刚打开时状态或者上一次 :w 保存的状态

     

    阿里云

    la -al `which python`
    

      

    ps -ef | grep 9200
    

     

    删除行

    :1,.d
    当前光标 delete to beginning of file
    
    :.,$d
    当前光标 delete to end of file
    
    :1,3d
    删除1到3行 # 注意没有0行
    

      

    复制内容

    ```

    :set paste

    ```

    • 后台运行python脚本
    python  run.py  >& logs.txt &
    

      

    • bash_history

    vim ~/.bash_history 
    history -r  # 退出前,删除当前会话的记录
    

      

  • 相关阅读:
    常用加密解密类(含3des)
    谷歌API(Ajax)
    flashpaper使用详解
    布置小窝
    CodeSimth数据访问层模板
    CodeSmith业务逻辑层模板
    CodeSimth生成实体类模板
    C# 参考之方法参数关键字:params、ref及out
    ALV 格式常用参数
    BOM输出
  • 原文地址:https://www.cnblogs.com/dzhs/p/8358989.html
Copyright © 2011-2022 走看看