
脚本
魄灠polan
互相学习
展开
-
Shell 获取参数方式 “getopts”
/# cat test#!/bin/sh#set -xwhile getopts ":a:b:c" opt;do case $opt in a) echo "a option $OPTARG" ;; b) echo "b option $OPTARG" .原创 2020-10-10 11:15:32 · 624 阅读 · 0 评论 -
Shell 常用命令
1. 反转文件内容如文件内如如下: test.txtabc输入如下命令后: cat test.txt|sed '1!G;h;$!d', 输出如下:cba原创 2020-08-26 10:10:30 · 103 阅读 · 0 评论 -
Shell Json编程
{ "guest_vlan": "1", "g_device": "wifi1", "a_device": "wifi0", "atf_enable": "0", "thermal_analytics": "1", "g_support_mode": "573.5Mbps", "a_support_mode": "1.201Gbps", "athinfo": [ { "radio": "2.4G"...原创 2020-08-16 21:37:06 · 1612 阅读 · 0 评论 -
Shell 二进制转16进制(openwrt)
因为openwrt不支持bc,obase,$(2#0xff)等命令(系统被裁减等原因),所以需要手动去把2进制转换成16进制,shell code如下:#!/bin/sha="00010010001101000101011001111000"start=1end=4debug_level="0x"for i in `seq 1 8`;do echo "***i:$i****" b=`echo $a|cut -c $start-$end` b1=`echo $b|cut -c 1原创 2020-07-30 15:18:57 · 1068 阅读 · 0 评论 -
ping ip并记录log
set todate=%date:~5,2%%date:~8,2%set pre=pingbaseset "filename=%pre%%todate%.txt"@echo off:secho %date% >> %filename%echo %time% >> %filename%ping -n 2 192.168.1.4 >> %filename%TIME...原创 2018-04-19 10:09:07 · 6742 阅读 · 0 评论 -
bat脚本-用于复制文件夹内所有内容
用于复制文件夹内内容到自定义的目录,主要用于复制模板目录set filename=%date:~0,4%%date:~5,2%%date:~8,2% %提取date中数据为:2018/04/12 --> 20180412%set filename="%filename%-xxxxxxxx-by" %为目录名字添加一些其他字符%md E:\02\2-O\%filename% ...原创 2018-04-20 09:48:08 · 17632 阅读 · 0 评论