运维Shell脚本小试牛刀(一)

运维Shell脚本小试牛刀(一)
运维Shell脚本小试牛刀(二)
一: Shell中循环剖析 for 循环.......
#!/bin/bash -
#==================================================================================================================
#
#
# FILE: countloop.sh
# USAGE: ./countloop.sh
# DESCRIPTION:
# OPTIONS: -------
# REQUIREMENTS: ---------
#
# BUGS: ------
# NOTES: --------
# AUTHOR: ---------YangGe (TOM) ,YangGe.freedom@icloud.com
# ORGANIZATION:
# CREATED: 2023-8-24 09:11:20
# REVISION: --------
#
#
#
#
#
#====================================================================================================================
for i in 1 2 3 4 5 6 #循环1~6
doecho "Thre for loop is run $i times."
done
echo "==============================================================================================================="for linux in Debian Redhat Suse Fedora Centos7 Ubunto
do
echo "current out system is ${linux}....."
done
echo "================================================================================================================"
#!/bin/bash -
#==================================================================================================================
#
#
# FILE: orcmdssub.sh
# USAGE: ./forcmdssub.sh
# DESCRIPTION:
# OPTIONS: -------
# REQUIREMENTS: ---------
#
# BUGS: ------
# NOTES: --------
# AUTHOR: ---------YangGe (TOM) ,YangGe.freedom@icloud.com
# ORGANIZATION:
# CREATED: 2023-8-24 09:11:20
# REVISION: --------
#
#
#
#
#
#====================================================================================================================
echo "Printing file list in /etc directory........"
for file in `ls /etc/*`
doecho "current print file is: $file"
done
#!/bin/bash -
#==================================================================================================================
#
#
# FILE: forcmdssub.sh
# USAGE: ./forcmdssub.sh
# DESCRIPTION:
# OPTIONS: -------
# REQUIREMENTS: ---------
#
# BUGS: ------
# NOTES: --------
# AUTHOR: ---------YangGe (TOM) ,YangGe.freedom@icloud.com
# ORGANIZATION:
# CREATED: 2023-8-24 09:11:20
# REVISION: --------
#
#
#
#
#
#====================================================================================================================
echo "Printing file list in /etc directory........"
for file in `ls /etc/*`
doecho "current print file is: $file"
done
[root@www shelldic]# cat forvarscoutents.sh
#!/bin/bash -
#==================================================================================================================
#
#
# FILE: forvarscoutents.sh
# USAGE: ./forvarscoutents.sh
# DESCRIPTION:
# OPTIONS: -------
# REQUIREMENTS: ---------
#
# BUGS: ------
# NOTES: --------
# AUTHOR: ---------YangGe (TOM) ,YangGe.freedom@icloud.com
# ORGANIZATION:
# CREATED: 2023-8-24 09:11:20
# REVISION: --------
#
#
#
#
#
#====================================================================================================================filenames="/etc/my.cnf /etc/vconsole.conf /etc/rsyncd.conf /etc/sestatus.conf /usr/local/rs.conf"
# 上面的文件名以空格分割for file in $filenames
do
[ -f $file ] && echo "The file $file was found.." || echo "***** ERROR: The file $file was missing.....*******"
# 如果是文件,则打印文件存在,如果不存在则打印丢失
done
#!/bin/bash -
#==================================================================================================================
#
#
# FILE: simplenestedfor.sh
# USAGE: ./simplenestedfor.sh
# DESCRIPTION:
# OPTIONS: -------
# REQUIREMENTS: ---------
#
# BUGS: ------
# NOTES: --------
# AUTHOR: ---------YangGe (TOM) ,YangGe.freedom@icloud.com
# ORGANIZATION:
# CREATED: 2023-8-24 09:11:20
# REVISION: --------
#
#
#
#
#
#====================================================================================================================
for (( i = 0; i < 30; i++ )) #外循环do
for (( j=0; j<160; j++ )) # 内循环
do
echo -n "* " #
doneecho "" #
done
二 : while循环
#!/bin/bash -
#==================================================================================================================
#
#
# FILE: whichreadfile.sh
# USAGE: ./whichreadfile.sh
# DESCRIPTION:
# OPTIONS: -------
# REQUIREMENTS: ---------
#
# BUGS: ------
# NOTES: --------
# AUTHOR: ---------YangGe (TOM) ,YangGe.freedom@icloud.com
# ORGANIZATION:
# CREATED: 2023-8-24 09:11:20
# REVISION: --------
#
#
#
#
#
#====================================================================================================================file=$1 # 将位置参数1的值赋值给变量file
if [ $# -lt 1 ];then # 如果脚本未指定参数,则打印使用方法并退出运行
echo "Usage: $0 FILEPATH"
exitfi
while read -r line # 使用read命令从标准输入读取文件的一行,并赋值给变量line
do
echo $line # 打印读取的行
done < "$file"
[root@www shelldic]# cat whilereadfile.sh
#!/bin/bash -
#==================================================================================================================
#
#
# FILE: whichreadfile.sh
# USAGE: ./whichreadfile.sh
# DESCRIPTION:
# OPTIONS: -------
# REQUIREMENTS: ---------
#
# BUGS: ------
# NOTES: --------
# AUTHOR: ---------YangGe (TOM) ,YangGe.freedom@icloud.com
# ORGANIZATION:
# CREATED: 2023-8-24 09:11:20
# REVISION: --------
#
#
#
#
#
#====================================================================================================================file=$1 # 将位置参数1的值赋值给变量file
if [ $# -lt 1 ];then # 如果脚本未指定参数,则打印使用方法并退出运行
echo "Usage: $0 FILEPATH"
exitfi
while read -r line # 使用read命令从标准输入读取文件的一行,并赋值给变量line
do
echo $line # 打印读取的行
done < "$file"
输出测试:
[root@www shelldic]# ./whilereadfile.sh /etc/sudo.conf
#
# Default /etc/sudo.conf file
#
# Format:
# Plugin plugin_name plugin_path plugin_options ...
# Path askpass /path/to/askpass
# Path noexec /path/to/sudo_noexec.so
# Debug sudo /var/log/sudo_debug all@warn
# Set disable_coredump true
#
# Sudo plugins:
#
# The plugin_path is relative to ${prefix}/libexec unless fully qualified.
# The plugin_name corresponds to a global symbol in the plugin
# that contains the plugin interface structure.
# The plugin_options are optional.
#
# The sudoers plugin is used by default if no Plugin lines are present.
Plugin sudoers_policy sudoers.so
Plugin sudoers_io sudoers.so#
# Sudo askpass:
#
# An askpass helper program may be specified to provide a graphical
# password prompt for "sudo -A" support. Sudo does not ship with its
# own passpass program but can use the OpenSSH askpass.
#
# Use the OpenSSH askpass
#Path askpass /usr/X11R6/bin/ssh-askpass
#
# Use the Gnome OpenSSH askpass
#Path askpass /usr/libexec/openssh/gnome-ssh-askpass#
# Sudo noexec:
#
# Path to a shared library containing dummy versions of the execv(),
# execve() and fexecve() library functions that just return an error.
# This is used to implement the "noexec" functionality on systems that
# support C<LD_PRELOAD> or its equivalent.
# The compiled-in value is usually sufficient and should only be changed
# if you rename or move the sudo_noexec.so file.
#
#Path noexec /usr/libexec/sudo_noexec.so#
# Core dumps:
#
# By default, sudo disables core dumps while it is executing (they
# are re-enabled for the command that is run).
# To aid in debugging sudo problems, you may wish to enable core
# dumps by setting "disable_coredump" to false.
#
# Set to false here so as not to interfere with /proc/sys/fs/suid_dumpable
#
Set disable_coredump false
相关文章:
运维Shell脚本小试牛刀(一)
运维Shell脚本小试牛刀(一) 运维Shell脚本小试牛刀(二) 一: Shell中循环剖析 for 循环....... #!/bin/bash - # # # # FILE: countloop.sh # USAGE: ./countloop.sh # DESCRIPTION: # OPTIONS: ------- # …...
screen命令,可以断开服务器连接,依旧能运行你的程序了
可以参考博客1:https://blog.csdn.net/nima_zhang_b/article/details/82797928 可以参考博客2:https://blog.csdn.net/herocheney/article/details/130984403 Linux中的screen是一个命令行工具,可以让用户在同一个终端会话中创建多个虚拟终端。它非常有…...
【ArcGIS Pro二次开发】(63):批量更改字段别名
在我工作中遇到的大多数图斑,字段名称一般是英文,字段别名是中文,使用起来是比较方便的。 但有时候也会遇到一些不一样的情况,不知是经过了怎样的处理,图斑的字段别名被修改成了和字段名称一样的英文,这样…...
redis全套参数配置及降级解决方案
文章目录 redis高可用核心参数配置1.Lettuce2.Jedis3.Redisson4.其他客户端 redis降级场景简介一、业务背景二、设计方案三、实现方案四、总结 redis高可用核心参数配置 1.Lettuce 提示:该客户端无主动探活机制,只能依赖于 OS KeepaAlive 机制…...
AMD即将上市大量中端显卡,为新显卡支付过高价格的日子可能结束
AMD在本周末(8月25日)的德国Gamescom活动中展示了两款新显卡和一些新的升级技术,这些新GPU的定价将与英伟达的GeForce RTX 4000卡竞争。 这是一件大事,因为新的Radeon RX 7700 XT和7800 XT卡占据了AMD Radeon RX 7000系列产品线…...
go学习一之go的初体验
go语言学习笔记 一、golang初体验: 1.简单体验案例: package main{ //把这个test.go归属到main import "fmt" //引入一个包 func main(){//输出hellofmt.Println("hello world")} }2.从案例学到的知识点: (1) go文件的后缀是.…...
智能制造产业链数字化转型、数字化互联工厂建设方案PPT
本资料来源公开网络,仅供个人学习,请勿商用,如有侵权请联系删除,更多浏览公众号:智慧方案文库 篇幅有限,无法完全展示,喜欢资料可转发评论,私信了解更多信息。...
【安卓】拿注册码的两种方式
【安卓】拿注册码的两种方式 文章仅用于学习交流,请勿利用文章中的技术对任何计算机系统进行入侵操作。利用此文所提供的信息而造成的直接或间接后果和损失,均由使用者本人负责。首发吾爱:https://www.52pojie.cn/thread-1826802-1-1.html言归…...
【C++】—— 异常处理
前言: 本期,我将给大家讲解的是有关 异常处理 的相关知识! 目录 (一)C语言传统的处理错误的方式 (二)C异常概念 (三)异常的使用 1、异常的抛出和捕获 1️⃣ 异常的…...
cookie和session是什么,区别是什么?
cookie HTTP 协议中的 Cookie 包括 Web Cookie 和浏览器 Cookie,它是服务器发送到 Web 浏览器的⼀ ⼩块数据。服务器发送到浏览器的 Cookie,浏览器会进⾏存储,并与下⼀个请求⼀起发送到服务器。通 常,它⽤于判断两个请求是否来⾃…...
linux的mmc子系统与块设备关联
1.前言 本文主要block组件的主要流程,在介绍的过程中,将详细说明和block相关的流程,涉及到其它组件的详细流程再在相关文章中说明。 2.主要数据结构和API 2.1 struct mmc_card Elemete Namestruct mmc_cardPathinclude/linux/mmc/card.hRe…...
【Spring MVC】
目录 🍮1 什么是 MVC ? 🎁2 Spring MVC 的连接 🍘2.1 RequestMapping 实现 POST 和 GET 请求 🥣2.2 GetMapping 只支持 GET 请求 🫖2.3 PostMapping 只支持 POST 请求 🍬3 Spring MVC 获取参数的…...
【ES】笔记-生成器函数与调用
function* function* 这种声明方式 (function关键字后跟一个星号)会定义一个生成器函数 (generator function),它返回一个 Generator 对象。 function * gen(){console.log("heloo generator")}如何调用呢?先看下里面的内容 返回…...
将Spring Boot与Redis集成
一、引言 1、SpringBoot: Spring Boot是一个用于创建独立且可执行的Spring应用程序的框架。它简化了基于Spring框架的应用程序的开发过程,并提供了一种快速和简便的方式来构建Java应用程序。 Spring Boot提供了自动配置机制,通过引入适当的…...
vue echarts
安装 npm i -D echarts使用 <script setup lang"ts"> import * as echarts from echarts import { onMounted } from vueonMounted(() > {interface DataItem {value: [string, number]}let myChart echarts.init(document.getElementById(main))let dat…...
idea上利用JDBC连接MySQL数据库(8.1.0版)
1.了解jdbc概念 JDBC(Java DataBase Connectivity,java数据库连接)是一种用于执行SQL语句的Java API,可以为多种 关系数据库提供统一访问,它由一组用Java语言编写的类和接口组成。JDBC提供了一种基准,据此可以构建 更高级的工具和接口&#…...
【100天精通python】Day47:python网络编程_Web编程基础
目录 1 网络编程与web编程 1.1 网络编程 1.2 web编程 2 Web开发概述 3 Web开发基础 3.1 HTTP协议 3.2 Web服务器 3.3 前端基础 3.4 静态服务器 3.5 前后端交互的基本原理 4 WSGI接口 4.1 CGI 简介 4.2 WSGI 简介 4.3 定义 WSGI 接口 4.4 运行 WSGI 服务 4.5…...
DockerCompose介绍与使用
DockerCompose介绍与使用 1、DockerCompose介绍 DockerCompose用于定义和运行多容器 Docker 应用程序的工具。 通过 Compose可以使用 YAML 文件来配置应用程序需要的所有服务。一个使用Docker容器的应用,通常由多个容器组成,使用Docker Compose不再需要…...
Windows Qt 5.12.10下载与安装
Qt 入门实战教程(目录) C自学精简实践教程 目录(必读) 1 Qt5.12.10下载 qt-opensource-windows-x86-5.12.10.exe 官方离线安装包 Download Source Package Offline Installers | Qt 下载巨慢(也可能很快) 只能下载到最新的&…...
RustDesk最新版本编译与打包
本文环境 主要参考: https://www.yuque.com/shikangsi/efy0cp/wei3g1?https://blog.csdn.net/hualuohuakai2014/article/details/121605631 问题 flutter 生成 bridge 文件。 先安装工具,再生成ffi文件。 PS C:\Users\Administrator> cargo ins…...
国防科技大学计算机基础课程笔记02信息编码
1.机内码和国标码 国标码就是我们非常熟悉的这个GB2312,但是因为都是16进制,因此这个了16进制的数据既可以翻译成为这个机器码,也可以翻译成为这个国标码,所以这个时候很容易会出现这个歧义的情况; 因此,我们的这个国…...
label-studio的使用教程(导入本地路径)
文章目录 1. 准备环境2. 脚本启动2.1 Windows2.2 Linux 3. 安装label-studio机器学习后端3.1 pip安装(推荐)3.2 GitHub仓库安装 4. 后端配置4.1 yolo环境4.2 引入后端模型4.3 修改脚本4.4 启动后端 5. 标注工程5.1 创建工程5.2 配置图片路径5.3 配置工程类型标签5.4 配置模型5.…...
.Net框架,除了EF还有很多很多......
文章目录 1. 引言2. Dapper2.1 概述与设计原理2.2 核心功能与代码示例基本查询多映射查询存储过程调用 2.3 性能优化原理2.4 适用场景 3. NHibernate3.1 概述与架构设计3.2 映射配置示例Fluent映射XML映射 3.3 查询示例HQL查询Criteria APILINQ提供程序 3.4 高级特性3.5 适用场…...
学校招生小程序源码介绍
基于ThinkPHPFastAdminUniApp开发的学校招生小程序源码,专为学校招生场景量身打造,功能实用且操作便捷。 从技术架构来看,ThinkPHP提供稳定可靠的后台服务,FastAdmin加速开发流程,UniApp则保障小程序在多端有良好的兼…...
智能在线客服平台:数字化时代企业连接用户的 AI 中枢
随着互联网技术的飞速发展,消费者期望能够随时随地与企业进行交流。在线客服平台作为连接企业与客户的重要桥梁,不仅优化了客户体验,还提升了企业的服务效率和市场竞争力。本文将探讨在线客服平台的重要性、技术进展、实际应用,并…...
Frozen-Flask :将 Flask 应用“冻结”为静态文件
Frozen-Flask 是一个用于将 Flask 应用“冻结”为静态文件的 Python 扩展。它的核心用途是:将一个 Flask Web 应用生成成纯静态 HTML 文件,从而可以部署到静态网站托管服务上,如 GitHub Pages、Netlify 或任何支持静态文件的网站服务器。 &am…...
微信小程序云开发平台MySQL的连接方式
注:微信小程序云开发平台指的是腾讯云开发 先给结论:微信小程序云开发平台的MySQL,无法通过获取数据库连接信息的方式进行连接,连接只能通过云开发的SDK连接,具体要参考官方文档: 为什么? 因为…...
智能分布式爬虫的数据处理流水线优化:基于深度强化学习的数据质量控制
在数字化浪潮席卷全球的今天,数据已成为企业和研究机构的核心资产。智能分布式爬虫作为高效的数据采集工具,在大规模数据获取中发挥着关键作用。然而,传统的数据处理流水线在面对复杂多变的网络环境和海量异构数据时,常出现数据质…...
2023赣州旅游投资集团
单选题 1.“不登高山,不知天之高也;不临深溪,不知地之厚也。”这句话说明_____。 A、人的意识具有创造性 B、人的认识是独立于实践之外的 C、实践在认识过程中具有决定作用 D、人的一切知识都是从直接经验中获得的 参考答案: C 本题解…...
C++.OpenGL (20/64)混合(Blending)
混合(Blending) 透明效果核心原理 #mermaid-svg-SWG0UzVfJms7Sm3e {font-family:"trebuchet ms",verdana,arial,sans-serif;font-size:16px;fill:#333;}#mermaid-svg-SWG0UzVfJms7Sm3e .error-icon{fill:#552222;}#mermaid-svg-SWG0UzVfJms7Sm3e .error-text{fill…...
