shell
潇洒的白杨树
学习中
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
shell
1. cat >> file << EOFhttps://www.cnblogs.com/chenjingchao/p/6259572.html1. 创建file文件2. 创建完成后,写入后面的内容3. EOF结束2. linux中的标准输入输出输入:standin 1. 从键盘中读取信息STDOUT与STDERR都会默认显示在终端输出:standout,standerror原创 2017-12-21 16:27:20 · 295 阅读 · 0 评论 -
Shell脚本安装成服务加入系统启动-service
#!/bin/bash# 向一个临时文件中写入配置的内容,两种形式service和systemctlsudo cat >/tmp/mysql-exporter-systemctl<<EOF[Unit]Description=Mysql ExporterAfter=network.target[Service]ExecStart= ...[Install]Want...原创 2018-02-08 16:50:31 · 5583 阅读 · 0 评论 -
在python程序中运行shell脚本
#!/usr/bin/python# 导入各种模块import sys...# 各种变量consul_ip = sys.argv[2]install_path = ......# 使用os.system()在python执行shell命令os.system('mkdir -p '+install_path)...# 进一步对变量进行处理成 “export install_...原创 2018-02-08 14:50:11 · 3101 阅读 · 0 评论 -
Shell脚本中执行sql语句操作
#!/bin/bash#等号左右不能有空格install_path=mysql_root_user="root"mysql_root_password=mysql_host=# 创建用户function create_mysql_user(){ mysql -u${mysql_root_user} -p${mysql_root_password} -e "GRANT REP...原创 2018-02-08 15:11:46 · 2044 阅读 · 0 评论 -
shell 判读命令的返回值
tar_com=`rpm -qa|grep tar`if [ -n tar_com ];then echo 'tar ok'else echo 'tar no'fi查看某个命令是否存在function download(){ if command -v wget &amp;gt; /dev/null 2&amp;gt;&amp;amp;1; then sudo wget ...原创 2018-04-08 11:17:10 · 33440 阅读 · 0 评论 -
查看命令是否存在
查看某个命令是否存在function download(){ if command -v wget > /dev/null 2>&1; then sudo wget ${package_url} -O kubernets.tar.gz mv kubernets.tar.gz ${install_path} elif comman...原创 2018-10-25 18:29:37 · 1017 阅读 · 0 评论 -
shell实现交互
read -p "you are sure you wang to xxxxxx?[y/n]" inputecho $inputif [ $input = "y" ];then echo "ok "fi原创 2018-10-25 18:34:28 · 5310 阅读 · 0 评论 -
判断字符串中是否包含某些字符
disk=`cat /etc/system-release`g1="CentOS Linux release 7"g2="haha"if [[ $disk =~ $g1 ]];then ehco "包含"fiif [[ ! $disk =~ $g1 ]];then ehco "不包含"fiif [[ ! $disk =~ $g2 ]];then echo "...原创 2018-10-25 18:42:09 · 3393 阅读 · 0 评论
分享