美文网首页
shell相关

shell相关

作者: authur_Wong | 来源:发表于2022-08-07 11:26 被阅读0次

echo

echo -e 会打印换行等转义符号

echo "$PATH" 双引号内的变量会自动解析,不需要拼接

read

read -p "提示信息" loginuser
         -r "支持转义信息读取"
         -t 指定多长时间超时

# 如果 loginuser 为空,默认值为admin
if [ -z "${loginuser}" ];then
    loginuser=admin
fi

在read语句之前添加  stty erase '^H'
此时用退格键就没问题了

pgrep

直接查看命令的进程号 pgrep adminservice

取代 ps aux | grep adminservice | grep -v grep | awk -F ' ' '{print $2}'

if

if cmd;then
   # 如果cmd执行成功,那么执行该分支
fi

if ! cmd; then
  # 如果cmd执行失败,那么走该分支
fi

cd /var/www/xxx || exit # 如果打开目录失败,那么退出

for

for i in aaa bbb ccc ddd;do
   echo $i
done

ip=($(/sbin/ip a | grep inet | grep -v 127.0.0.1 | grep -v inet6 | awk -F ' ' '{print $2}'))
for i in  $(seq ${#ip[@]});do
  tmp=$(echo "${ip[i-1]}" | sed 's/\/[[:alnum:]]\{2\}//')
  echo "    网卡编号: $i. $tmp"
done

ss

查看系统socket 统计信息
ss -s

Total: 2148
TCP:   271 (estab 35, closed 214, orphaned 1, timewait 206)

Transport Total     IP        IPv6
RAW       2         0         2        
UDP       32        25        7        
TCP       57        44        13       
INET      91        69        22       
FRAG      0         0         0        

查看当前进程的文件打开数:lsof -p 2324 | wc –l
查看当前端口的文件打开数:lsof -i:80 | wc -l
查看当前所有进程文件打开数:lsof | wc -l

sed 替换

sed -i "1,2s/dest/replace/" file  # 替换第1到2行的dest为replace

axel

axel --help
Usage: axel [options] url1 [url2] [url...]

--max-speed=x           -s x    Specify maximum speed (bytes per second)
--num-connections=x     -n x    Specify maximum number of connections
--max-redirect=x                Specify maximum number of redirections
--output=f              -o f    Specify local output file
--search[=n]            -S[n]   Search for mirrors and download from n servers
--ipv4                  -4      Use the IPv4 protocol
--ipv6                  -6      Use the IPv6 protocol
--header=x              -H x    Add HTTP header string
--user-agent=x          -U x    Set user agent
--no-proxy              -N      Just don't use any proxy server
--insecure              -k      Don't verify the SSL certificate
--no-clobber            -c      Skip download if file already exists
--quiet                 -q      Leave stdout alone
--verbose               -v      More status information
--alternate             -a      Alternate progress indicator
--help                  -h      This information
--timeout=x             -T x    Set I/O and connection timeout
--version               -V      Version information

eg:
axel -n 10 https://mirrors.aliyun.com/centos/7.9.2009/isos/x86_64/CentOS-7-x86_64-Minimal-2207-02.iso\?spm\=a2c6h.25603864.0.0.34ea6aeaDqg255

相关文章

  • adb shell 命令相关功能

    adb shell 命令相关功能 Tags: adb_shell adb shell wm 命令获取屏幕相关信息 ...

  • shell相关

    命令,脚本 shell基本命令clear 清屏 cd – 后退 cd $MYPATH 进入指定目录(环境变量已设)...

  • Shell相关

    1.1 注册shell上下文 在使用flask shell进入命令行 我们可以直接使用db, Note对象

  • shell 相关

    shell脚本执行错误 $'\r':command not found 存现这种错误是因为 编写的 shell脚...

  • shell相关

    因为默认的shell是bash,所以大部分说明可以从man bash拿到。命令具体是否在bash内部,可以通过ty...

  • shell相关

    echo echo -e 会打印换行等转义符号 echo "$PATH" 双引号内的变量会自动解析,不需要拼接 r...

  • Shell_Shell 脚本中字符串的相关操作

    Shell_Shell 脚本中字符串的相关操作

  • Linux的shell script

    Linux的shell script 相关例子:

  • Xamarin.FormsShell基础教程(9)Shell相关

    Xamarin.FormsShell基础教程(9)Shell相关类体系 在Shell中,最为主要的类是Shell类...

  • docker 构建hadoop 环境

    技能库 docker 相关 linux 相关 shell 相关 hadoop hive 准备文件 jdk 安装包:...

网友评论

      本文标题:shell相关

      本文链接:https://www.haomeiwen.com/subject/xtkwwrtx.html