Linux常用命令合集(日常整理)

    xiaoxiao2025-07-24  17

    开进程并发下载

    for ((s=1987;s<2019;s=s+1)) do for ((m=1;m<13;m=m+1)) do aa=($s'_'$m) echo $aa wget https://transtats.bts.gov/PREZIP/On_Time_Reporting_Carrier_On_Time_Performance_1987_present_$aa.zip & done done

    远程复制

    从前面的文件夹复制到后面的文件夹 scp -r remote_username@remote_ip:remote_folder local_folder

    查看外网ip

    curl -L tool.lu/ip

    查看文件大小

    du -h --max-depth=0 ./2017_credits.txt

    查看ip

    ip addr show

    看日志

    看线上日志要用less/more,千万别用vi,vi会一次把文件全读入,内存耗光

    远程文件弄到本地文件夹

    shutil.copy(remote_file, local_file_dir)

    echo导出select数据

    echo "select * from miveshow_money.user_credits_history limit 1" | mysql -umiveshow -h10.0.110.115 -pmiveshow123 -Dmiveshow > o

    统计文件和文件夹的总量

    ls | wc -l

    统计文件个数

    ls -l |grep "^-"|wc -l

    统计当前目录下的所有目录

    文件以-开头 目录以d开头 1、ls -l | grep "^d" 目录以/结尾 2、ls -F | grep "/$" 配合查看文件数量的命令查看目录数量 ls -l | grep "^d" | wc -l

    排序、去重

    sort -n test.txt | uniq

    grep多个关键字(or)

    grep file.txt -E "aaa|bbb|ccc"

    删除多行

    删除多行,闭区间[1,999]

    vi file.txt :1,999d

    覆盖方式生成文件

    cat file.log | grep test > result.txt

    生成或追加到文件

    cat file.log | grep test >> result.txt
    最新回复(0)