随笔分类 - LINUX / Linux 脚本
linxu scripts
摘要:配置 配置INPUT链:iptables -I INPUT -s xxxx -j ACCEPT 配置OUTPUT链:iptables -I OUTPUT -d xxxx -j ACCEPT 查看 iptables -L -n -v 可以在-L后指定 INPUT/OUTPUT 链 脚本 #/bin/b
阅读全文
摘要:脚本 #!/usr/bin/python3 import sys import requests import json from termcolor import colored url = 'https://fanyi.baidu.com/sug' data = {'kw': sys.argv[
阅读全文
摘要:网上下载了一个英语词根和英语单词文件,包含导入到数据库的sql语句:english-root.sql和english_word.sql,于是写个脚本辅助背单词。 脚本 脚本逻辑:通过随机数获得词根编号,取得词根,过滤出其中的词根字符,并从数据库中提取以这些词根字符开头的单词。 脚本操作:接收一个传入
阅读全文
摘要:``` #!/bin/bash passwd= if [ $# -ne 1 ] then echo "$0 [31|37|61]" fi if command -v sshpass then sshpass -p $passwd ssh -o StrictHostKeyChecking=no roo
阅读全文
摘要:``` #!/bin/bash ip=$1 ip_num=$(echo $ip | awk -F\. '{print NF}') if [ $ip_num -eq 2 ]; then ip=192.168.$ip fi shift cmd=$@ if echo "$cmd" | grep -E "r
阅读全文
摘要:Guess_the_Number.py import random # Generate a random number between 1 and 100 number = random.randint(1, 100) # Set the initial number of guesses to
阅读全文
摘要:命名:log_extractor.py or download_stats_extractor.py # coding:utf-8 #!/usr/bin/python3 def filter_line(line,contains,contains_not): if all(c in line for
阅读全文
摘要:下面这段代码中,变量cur表示这次循环所要处理的参数。如果没有触发前面的选项开关,第一个参数会被赋值给$DISK,第二个参数会赋值给$PART。 强无敌!~ while [ $# -ne 0 ]; do cur=${1} next=${2} case "$cur" in -h|--help) Usa
阅读全文
摘要:| 类型 | 示例 | 用途 | | | : : | | | 大写的变量名 | IP | 表示常量,比如,用来记录输入和输出文件名 | | 小写变量名 | mac | 一般变量 | | 左边下划线 | mac | 临时的中间变量,只引用一次的变量 | | 右边下划线 | tmpfile | 临时文件
阅读全文
摘要:#!/bin/bash # 设置并发数 thread_num=3 # 创建管道文件 FIFO=/tmp/$$-FIFO mkfifo $FIFO # 使用句柄打开管道文件 exec 1000<>$FIFO rm -f $FIFO # 向管道里面输入若干行 for i in `seq $thread_
阅读全文
摘要:logging #!/bin/bash # a small tool for logging sommething # # 1. read your input # 2. save to logs file >> ~/logs/$(date +%F) # # if command like: log
阅读全文
摘要:#!/bin/bash ips=( 1.1.1.2 1.1.1.1 ) port= user= passwd= for i in ${ips[@]} do echo "== $i ==" sshpass -p "$passwd" ssh -p $port $user@$i "$@" done
阅读全文
摘要:#!/usr/bin/expect if {$argc != 1} { puts "usage: ./telnet2sswitch <r2|r3>" exit } if {"[lindex $argv 0]" == "r0"} {set ip 192.168.130.10 } if {"[linde
阅读全文
摘要:#!/bin/bash ips=( 1.1.1.1 1.1.1.2 ) user= passwd= for i in ${ips[@]} do echo "== $i ==" sshpass -p "$passwd" scp -P 26222 $@ $user@$i:/tmp/ done
阅读全文
摘要:[root@dev-clickhouse1 ~]# cat ch-manager.sh #!/bin/bash ch_arr=(ch1-shard1-main ch1-shard2-sub ch2-shard2-main ch2-shard3-sub ch3-shard3-main ch3-shar
阅读全文
摘要:#!/bib/bash DIR=/tmp cd $DIR || { echo "Dir not Found: $Dir" exit } echo "Delete a file from 90 days if it is not in use, skip hidden files. " ff="$(f
阅读全文
摘要:以终为始 initramfs_cgz=/srv/initrd/osimage/$os/$os_arch/${os_version%-iso}/$(date +"%Y%m%d").0.cgz mkdir -p $(dirname $initramfs_cgz) cd /srv/os/openeuler
阅读全文
摘要:#!/bin/bash dst_dir=${2:-/tmp} # 当 $2 为空或null时,设置默认值。 docker cp prometheus:$1 $dst_dir
阅读全文

浙公网安备 33010602011771号